0

i have created an app in flutter language and it worked perfect at the beginning then after i flutter pub get it stopped running in vs code and i'm getting this error

java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused: connect

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:foodies_app/breakfast.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:footer/footer.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:video_player/video_player.dart';
import 'package:footer/footer_view.dart';
import 'package:localize_and_translate/localize_and_translate.dart';

// void main() => runApp(MyApp());

main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await translator.init(
    localeType: LocalizationDefaultType.device,
    languagesList: <String>['ar', 'en'],
    assetsDirectory: 'assets/langs/',
    // apiKeyGoogle: '<Key>', // NOT YET TESTED
  ); // intialize

  runApp(LocalizedApp(child: MyApp()));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Home(),
      localizationsDelegates: translator.delegates, // Android + iOS Delegates
      locale: translator.locale, // Active locale
      supportedLocales: translator.locals(),
      title: 'Flutter Demo',
      theme: ThemeData(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  VideoPlayerController _controller;
  @override
  @override
  @override
  void initState() {
    super.initState();
    // Pointing the video controller to our local asset.
    _controller = VideoPlayerController.asset("assets/02.mp4")
      ..initialize().then((_) {
        // Once the video has been loaded we play the video and set looping to true.
        _controller.play();
        _controller.setLooping(true);
        // Ensure the first frame is shown after the video is initialized.
        setState(() {});
      });
    @override
    void dispose() {
      super.dispose();
      _controller.dispose();
    }
  }

  Widget build(BuildContext context) {
    return

        Scaffold(
            // TODO 6: Create a Stack Widget
            body: Stack(children: <Widget>[
      // TODO 7: Add a SizedBox to contain our video.
      SizedBox.expand(
        child: FittedBox(
          // If your background video doesn't look right, try changing the BoxFit property.
          // BoxFit.fill created the look I was going for.
          fit: BoxFit.fill,
          child: SizedBox(
            width: _controller.value.size?.width ?? 0,
            height: _controller.value.size?.height ?? 0,
            child: VideoPlayer(_controller),
          ),
        ),
      ),
    ]));
  }
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
sara97
  • 209
  • 2
  • 11

1 Answers1

0

wipe the emulator data from the ADB manager edit: I had the same issue on my Mac, the solution was to go to ADB manager on android studio and wipe the emulator data like the screenshot provided: enter image description here

MOUKZ
  • 91
  • 4