How to change background color of launch screen icon in flutter?

29 Views Asked by At

Here is the content of my style.xml

@color/background @color/background This Theme is only used starting with V2 of Flutter's Android embedding. --> <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> <item name="android:windowBackground">@color/background</item> </style>

and I am getting following error:

style attribute 'android:attr/windowSplashScreenIconBackground' not found.

If I try to extend Theme.SplashScreen.IconBackground following the suggestion given in Icon background color in Android 12 Splash Screen does not work, the parent class (specified as parent="@android:style/Theme.SplashScreen.IconBackground") is not identified and getting error too like:

style attribute 'android:attr/windowSplashScreenIconBackground' not found.

Please do not suggest flutter_native_splash package it didn't work. My minSDK = 31, targetSDK = 34.

With the following style.xml, I am able to change the background color to my wish, but I am getting the white icon background color which I need to change to the background color.

@color/background @color/background This Theme is only used starting with V2 of Flutter's Android embedding. --> <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> <item name="android:windowBackground">@color/background</item> </style>

This is the screenshot of resulted launch screen

enter image description here

1

There are 1 best solutions below

2
Emsil Neumann On

To change the background color of the launch screen icon in Flutter, you must to define a "custom theme" in your styles.xml file.

However, changing the background colr of the launch scren icon itself is not directly supported via standard flutter theming or XML styles. The icon's background color is controlled by the system and might be affected by the theme or system settings.

If you're targeting Android 12 (SDK 31+),try to customize the splash screen appearance,including the icon background color, by defining a custom theme that extends here >> Theme.SplashScreen.IconBackground.

As faras I know there's no built-in Flutter solution to direct change the background of the launch screen without resorting to platform-specific customization. did you check flutter_native_splash package ?

Or you can create a image via littiefiles (lottiefiles.com) for dynamic style. That helped me to skip many styling issues.