Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Splash Screen

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)

like image 396
Vikas Avatar asked Apr 05 '18 09:04

Vikas


People also ask

How do you make a splash screen in Flutter?

To do so, open the Flutter app's Xcode project by typing open ios/Runner. xcworkspace from the root of your app directory. Then select Runner/Assets. xcassets from the Project Navigator and drop in the desired images to the LaunchImage image set.

What is splash in Flutter?

A splash screen is a launch screen, start screen, or boot screen, which is a graphical control element containing the image, logo, and current version of the software. It is the first screen of the app that displays whenever the application is loading.


1 Answers

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
  }
}
like image 79
Shady Aziza Avatar answered Nov 15 '22 10:11

Shady Aziza