英文:
flutter error Looking up a deactivated widget's ancestor is unsafe
问题
我试图让启动屏幕只显示5秒钟,但我遇到了以下错误。flutter错误
我的Dart代码splashScreen代码
英文:
I am trying to make the splashscreen display for 5 seconds only but I have the following error.flutter error
my dart codesplashScreen code
答案1
得分: 0
将SplashScreen类转换为StatefulWidget。然后在initState()中,延迟4秒后进行导航。
@override
void initState() {
Future.delayed(const Duration(seconds: 4)).then((value) {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
return const HomePage();
}));
});
super.initState();
}
英文:
convert SplashScreen class into StateFulWidget.
then inside initState() navigate after 4 seconds.
@override
void initState() {
Future.delayed(const Duration(seconds: 4)).then((value) {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
return const HomePage();
},));
});
super.initState();
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论