[英]How to change time for splash screen using flutter_native_splash package in flutter?
I want to Change the Splash Screen time by using flutter_native_splash package.我想通过使用 flutter_native_splash package 来更改启动画面时间。
So how i can change the splash screen time?那么我怎样才能改变闪屏时间呢?
You should not use splash_screen to delay the user intentionally.您不应故意使用 splash_screen 来延迟用户。 Instead you should use splash_screen to load all necessary data background and close splash as soon as the app data is loaded from the internet.
相反,您应该使用 splash_screen 加载所有必要的数据背景,并在从 Internet 加载应用程序数据后立即关闭启动画面。
If you also read through the package you will see in the FAQ the following:如果您还阅读了 package,您将在常见问题解答中看到以下内容:
Can I change the duration of the splash screen?我可以更改启动画面的持续时间吗?
The native splash screen is displayed while the native app loads the Flutter framework.当本机应用程序加载 Flutter 框架时,会显示本机启动画面。 Because the resources in your app cannot load while the native splash screen is displayed, the native splash screen must be as fast as possible.
由于在显示原生闪屏时无法加载应用中的资源,因此原生闪屏必须尽可能快。 Note that delaying the user experience is a poor design decision.
请注意,延迟用户体验是一个糟糕的设计决策。
So, you should only use splash screen to load contents from the internet to your app.因此,您应该只使用闪屏将内容从互联网加载到您的应用程序。
@Kamrul is right you should not add intentional delay in your app. @Kamrul 是对的,您不应该在您的应用程序中故意添加延迟。 But if it is client's requirement as I used to have one in one of my project just change your "main function" located in main.dart as following.
但是,如果这是客户的要求,因为我曾经在我的项目之一中有一个,只需更改位于 main.dart 中的“主要功能”,如下所示。
void main() async {
await Future.delayed(Duration(seconds: 3));
runApp(MyApp());
}
Here are the changed I've made in the default main function.这是我在默认主 function 中所做的更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.