创建一个DummyPage
小部件,它会在2秒后将您带到YourHomePage
(您的应用程序的主要小部件)。
更新:我之前使用了Timer
,但它需要导入额外的库,您可以按照@anmol. majhail的建议使用Future.delay
void main() {
runApp(MaterialApp(home: DummyPage()));
}
class DummyPage extends StatefulWidget {
@override
_DummyPageState createState() => _DummyPageState();
}
class _DummyPageState extends State<DummyPage> {
@override
void initState() {
super.initState();
// here is the logic
Future.delayed(Duration(seconds: 2)).then((__) {
Navigator.push(context, MaterialPageRoute(builder: (_) => YourHomePage()));
});
}
@override
Widget build(BuildContext context) {
return Container(); // this widget stays here for 2 seconds, you can show your app logo here
}
}