Check Mobile App
Read now
Start a Project

SplashScreen Support for Android12 in Flutter

Save

SplashScreen basically, the SplashScreen is the first screen that appears when the user opens up any application.

So, it is mandatory that SplashScreen must be innovative as well as eye-catching. No one will like to see a black/white screen at first.

In Flutter, we have two options to add on SplashScreen in the app

  1. With the help of Native Code in the ic_launcher_background.xml file
  2. We can even customize the SplashScreen with the help of widgets

We have learned about the methods to create SplashScreen in Flutter but writing the code within just the ic_launcher_background.xml file was supported till Android11.

If you will try to run the same app in Android12, it will display a black screen with a logo in the center.

So, Now comes the issue, that How can we have a Splash Screen which supports the Android12?

Implementation of SplashScreen Support for Android12 in Flutter

Let’s start the implementation-

Step – 1 -> Firstly, we will need to create an Android Resource Directory in the android -> app folder, where the resource type will be “values“.

While creating the directory, we will need to add the version from “Available Qualifiers” and set it as 31.

After creating the directory, we will find it on the path android/app/main/res/values-v31

Step – 2 -> Create a new file named “styles.xml” and add the following code-

Here, we have added the windowSplashScreenBackground, windowSplashScreenAnimatedIcon and postSplashScreenTheme.

windowSplashScreenBackground – It specifies the background color for the SplashScreen.

windowSplashScreenAnimatedIcon – It specifies the path of the icon for the SplashScreen.

postSplashScreenTheme – It specifies the Theme that will be launched after the SplashScreen has completed the loading.

Step – 3 -> After that we will have to add a dependency on android/app/build.gradle level

Step – 4 -> We will have to write a few lines of code in Main.Activity file either in JAVA or in Kotlin.

Step – 5 -> Now, we will have to add the Theme we have created into the AndroidManifest.xml file.

After writing this code, if we try to run your app on the device, it will still not show the Splash Image

The reason is that it will still not able to detect the correct theme for the Android12, so we will need to add the theme details in the styles.xml file in the values folder as well.

 

Conclusion

In this blog, we have discussed how can we add Splash Screen in Flutter Apps running on devices having Android 12.

I hope it will help you out in understanding.

Thanks for reading!!

References

https://docs.flutter.dev/development/ui/advanced/splash-screen

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Very good company, we did get app extension for Magento 2 website. The support was very good they help us through the process. Webkul team is very supportive, I would recommend them.

Yasser Mohamed

Yasser Mohamed

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home