fluttersplash-screendynamic-splash-screen

How to add a real splash screen in flutter


I have a splash_screen.dart flutter page, in my main.dart, this page is used to check if the user is already connected but it is not a real splash screen ... my page is displayed when starting the app?

I looked on the styles.xml side (for android) but I only found solutions to add an image ...

I have to write my splash_screen.dart page in java in styles.xml?

thanks for your help


Solution

  • In Android, there are two separate screens that you can control: a launch screen shown while your Android app initializes, and a splash screen that displays while the Flutter experience initializes.

    Every Android app requires initialization time while the operating system sets up the app’s process. Android provides the concept of a launch screen to display a Drawable while the app is initializing.

    The default Flutter project template includes a definition of a launch theme and a launch background.

    You can customize this by editing styles.xml, where you can define a theme whose windowBackground is set to the Drawable that should be displayed as the launch screen.

    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    

    check the offical docs for more