颤动闪屏 [英] Flutter Splash Screen
本文介绍了颤动闪屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在闪屏中显示闪屏?因此,有一个启动图标选项。我在各自的文件夹中添加了适用于ios和android的图像。我的问题是速度太快。因此,它直接打开MyApp()。我希望我的应用程序不显示任何内容,并让Splash进行控制,直到我弄清楚该将用户带到哪个屏幕为止(在MyApp中,我想进行初始化)
How do I show a splash Screen in flutter? So there is an option for launch icon. I added images for ios and android in their respective folders. My problem is it is too fast. So it directly opens MyApp(). I want my app to not show anything and let splash take control until I figure out which screen to take the user to (In MyApp I want to do intialization)
推荐答案
您可以在 initState
中使用 Future.delayed
构造函数。
You can use Future.delayed
constructor in your initState
. This will keep your SplashScreen for the duration you specify before the navigation happen.
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => new _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState (){
super.initState();
// TODO initial state stuff
new Future.delayed(const Duration(seconds: 4));
}
@override
Widget build(BuildContext context) {
//build
}
}
这篇关于颤动闪屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文