Home > OS >  Need to implement Native splash screen for 2 seconds in flutter
Need to implement Native splash screen for 2 seconds in flutter

Time:06-01

I have used flutter plugin flutter_native_splash: ^2.2.2

I need to implement splash screen exact for 2 seconds with custom image. I tried all examples from plugin description but not worked perfectly.

flutter_native_splash:

  background_image: "assets/images/splash.png"

CodePudding user response:

It is not possible to display a Flutter native splash screen for an exact amount of time, because the splash is displayed while the Flutter framework is loaded. Depending on the processing speed of the device, this may take more or less time. Conceivably, on an older device, it could last longer than two seconds even if you did not add an additional delay.

CodePudding user response:

You can try this code in main method:

void main() async{
  await Future.delayed(const Duration(seconds: 2))
      .then((value) => FlutterNativeSplash.remove());
  runApp(const MyApp());
}
  • Related