黑屏在我的Flutter应用的启动画面之前出现和消失。
黑屏在我的Flutter应用的启动画面之前出现和消失。
我正在开发一个Flutter应用程序,当我打开应用程序时,会出现一个黑屏,然后才会出现启动画面,这真的很烦人。这是我的启动画面代码:
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State
@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,
),
),
),
);
}
}
这是我的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:
// 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(),
},
);
}
}
希望有人能帮我解决这个问题。
我的Flutter版本是v1.12.13+hotfix.7
我之前用Flutter SDK的旧版本(v1.12.13+hotfix.6)完成了一个Flutter应用程序,那个应用程序没有出现这个错误。