1

i am developing a flutter app and when i open the app a black screen come and go before the splash screen appear.its really annoying. Here is my splash screen code

   class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  void initState() {
    super.initState();
    Future.delayed(
      Duration(seconds: 3),
      () {
        Navigator.pop(context);
        Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => LoginPage(),
          ),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    // final double width = MediaQuery.of(context).size.width;

    return Scaffold(
      backgroundColor: Color.fromRGBO(245, 246, 250, 1),
      body: DelayedReveal(
        delay: Duration(milliseconds: 1200),
        child: Center(
          child: Image.asset(
            'assets/images/logo.png',
            width: 280,
            height: 280,
          ),
        ),
      ),
    );
  }
}

Here is my main.dart

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Folk',
      theme: ThemeData(
        primarySwatch: Colors.orange,
      ),
      home: new SplashScreen(),
      routes: <String, WidgetBuilder>{
        // login and resgistration routes
        "/login": (BuildContext context) => new LoginPage(),
        "/phonelogin": (BuildContext context) => new PhoneLogin(),
         "/forgotpw": (BuildContext context) => new ForgotPassword(),
        "/resetpw": (BuildContext context) => new ResetPassword(),
        "/pincode": (BuildContext context) => new PincodeVerify(),
        "/setupstep1": (BuildContext context) => new SetupStepOne(),
        "/setupstep2": (BuildContext context) => new SetupStepTwo(),
        "/setupstep3": (BuildContext context) => new SetupStepThree(),
        "/location": (BuildContext context) => new GetLocation(),
        "/SettingUpScreen": (BuildContext context) => new SettingUpScreen(),

        //homepage routes
        "/home": (BuildContext context) => new Homepage(),
      },
    );
  }
}

Hope someone would help me to solve this.

my flutter version is v1.12.13+hotfix.7

i have done a flutter app with the previous version of the flutter sdk (v1.12.13+hotfix.6) and that app didn't give me this error

0 Answers0