Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter v2.5.0 Android Splash Screen

I had implemented a native splash screen in my current project and everything was working correctly since I upgraded to v2.5.0 and I am starting to get this deprecation warning on my console:

A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.

I have checked out the given link (which is not that clear btw) and tells me to remove the o.flutter.embedding.android.SplashScreenDrawable API as flutter now automatically displays the splash.

But after running my app without the code no splash screen appears moreover it takes a while to start the app - probably initializing the app without the splash or something.

Am I doing this right or is it an issue with the framework itself?

like image 979
Muhammad Idrees Avatar asked Sep 11 '21 08:09

Muhammad Idrees


People also ask

Where is AndroidManifest XML in flutter?

Android app manifest file, AndroidManifest. xml is located in <app dir>/android/app/src/main. It contains entire details about an android application.

How do you create a splash screen?

The most straightforward way to create a simple splash screen was to create a dedicated theme overriding android:windowBackground with a drawable containing branding colors or a bitmap of a logo. The theme was set as an attribute of the launcher activity in AndroidManifest. xml.

Is a native Android splash screen deprecated in flutter?

I had implemented a native splash screen in my current project and everything was working correctly since I upgraded to v2.5.0 and I am starting to get this deprecation warning on my console: A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.

How to change the splash screen color in flutter?

If you want to change the black and white splash screen color you need to edit the files in the native projects. Set the background color in the native projects to equal the flutter splash screen background color it will result in a really smooth transition between the native splash and the flutter one.

What is a splash screen in mobile app development?

Adding a splash screen is one of the essential steps in a mobile app development process. It is the first screen that appears for a second or two when we launch any Android or iOS app before the main page loads. Also known as a launch screen, it serves as an initial, positive experience for your users.

How do I create a launch screen in flutter?

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.


4 Answers

It is caused by having the following code in your AndroidManifest.xml, which was included by default in previous versions of Flutter:

<meta-data
    android:name="io.flutter.embedding.android.SplashScreenDrawable"
    android:resource="@drawable/launch_background"
/>

The solution is to remove the above code.

Source

like image 139
Sander Roest Avatar answered Oct 17 '22 13:10

Sander Roest


Follow this youtube tutorial on how to correctly Create Splash Screen in Flutter App the Right Way in 2021. Ensure to create the launch_background.xml file in both drawable and drawable-v21 folders inside the android/app/src/main/res folder.

Create Splash Screen in Flutter App the Right Way in 2021

If you are using Flutter 2.5, remove the following line in your AndroidManifest.xml file since Flutter 2.5 has no need for it anymore as mentioned here --> android splash migration

<meta-data
 android:name="io.flutter.embedding.android.SplashScreenDrawable"
 android:resource="@drawable/launch_background"/>
like image 44
Tobechukwu Ezenachukwu Avatar answered Oct 17 '22 13:10

Tobechukwu Ezenachukwu


Remove the below lines from your AndroidManifest.xml file. In newer versions it's no longer used

<meta-data
     android:name="io.flutter.embedding.android.NormalTheme"
     android:resource="@style/NormalTheme" />
            
<meta-data
      android:name="io.flutter.embedding.android.SplashScreenDrawable"
      android:resource="@drawable/launch_background" />
like image 5
Hardik Hirpara Avatar answered Oct 17 '22 14:10

Hardik Hirpara


Here is one solution that worked in my case.

You have a "drawable" and "drawable-v21" folders on the path "android/app/src/main/res/" and you must open the "launch_background.xml" in "drawable-v21" folder, paste and a little bit refactor my code to provide your image or/and color:

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/your_color" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/your_image" />
    </item>
</layer-list>

P.S. The image should be in "drawable" folder, not "drawable-v21". You can try, but in my case that didnt work and throw the error.

P.S.2 I didn't change the "AndroidManifest.xml", "styles.xml" and other files.

like image 1
Puxlozadiy Avatar answered Oct 17 '22 12:10

Puxlozadiy