Home > Net >  How to change time for splash screen using flutter_native_splash package in flutter?
How to change time for splash screen using flutter_native_splash package in flutter?

Time:11-26

I want to Change the Splash Screen time by using flutter_native_splash package.

So how i can change the splash screen time?

CodePudding user response:

You should not use splash_screen to delay the user intentionally. 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.

If you also read through the package you will see in the FAQ the following:

Can I change the duration of the splash screen?

The native splash screen is displayed while the native app loads the Flutter framework. 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.

CodePudding user response:

@Kamrul is right you should not add intentional delay in your app. 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.

void main() async {
    await Future.delayed(Duration(seconds: 3));
    runApp(MyApp());
}

Here are the changed I've made in the default main function.

  1. I've made it asynchronous by adding async right after the parentheses.
  2. In second line I've told the main function to wait until the future is resolved by adding custom delay of 3 seconds.
  • Related