Skip to content

flutter_native_splash Android 12+ Color Update Issue #814

@rmahfouz

Description

@rmahfouz

Bug Report: flutter_native_splash Android 12+ Color Update Issue

Summary

The flutter_native_splash plugin (v2.4.7) does not properly update the android:windowSplashScreenBackground color in Android 12+ style files when regenerating splash screens. The plugin keeps hardcoded color values instead of reading from flutter_native_splash.yaml.

Environment

  • Plugin Version: flutter_native_splash 2.4.7
  • Flutter Version: 3.38.5
  • Dart Version: 3.10.4
  • Target Platform: Android 12+ (API 31+)
  • OS: Windows 11

Steps to Reproduce

  1. Create a Flutter project with flutter_native_splash configured in flutter_native_splash.yaml:

    flutter_native_splash:
      color: "#FFFFFF"
      image: assets/splash.png
      color_dark: "#042a49"
      image_dark: assets/splash_dark.png
      android_12:
        image: assets/splash.png
        image_dark: assets/splash_dark.png
        color: "#FFFFFF"
        color_dark: "#042a49"
  2. Run dart run flutter_native_splash:create

  3. Change the colors in flutter_native_splash.yaml:

    color: "#FF00FF"  # Changed from white to magenta
    color_dark: "#00FFFF"  # Changed from dark blue to cyan
  4. Run dart run flutter_native_splash:create again

  5. Build and run the app on an Android 12+ device/emulator

Expected Behavior

The splash screen background should update to the new colors (magenta and cyan).

Actual Behavior

The splash screen continues to show the old colors (white and dark blue). The plugin regenerates all files but does not update the android:windowSplashScreenBackground values in:

  • android/app/src/main/res/values-v31/styles.xml
  • android/app/src/main/res/values-night-v31/styles.xml

Root Cause

When the plugin runs, it updates these files:

[Android]  - android/app/src/main/res/values-v31/styles.xml
[Android]  - android/app/src/main/res/values-night-v31/styles.xml

However, the android:windowSplashScreenBackground property retains the first color value it was generated with and ignores subsequent changes in flutter_native_splash.yaml.

Affected Files

android/app/src/main/res/values-v31/styles.xml (Line 9):

<item name="android:windowSplashScreenBackground">#FFFFFF</item>
<!-- This stays #FFFFFF even after changing color in YAML -->

android/app/src/main/res/values-night-v31/styles.xml (Line 9):

<item name="android:windowSplashScreenBackground">#042a49</item>
<!-- This stays #042a49 even after changing color_dark in YAML -->

Workaround

Manually edit the Android 12+ style files after running dart run flutter_native_splash:create:

  1. Open android/app/src/main/res/values-v31/styles.xml

  2. Find line with android:windowSplashScreenBackground

  3. Change the color to match your color value from flutter_native_splash.yaml

  4. Open android/app/src/main/res/values-night-v31/styles.xml

  5. Find line with android:windowSplashScreenBackground

  6. Change the color to match your color_dark value from flutter_native_splash.yaml

  7. Uninstall the old app: adb uninstall <your.package.name>

  8. Rebuild and run: flutter run

Additional Notes

  • This issue only affects Android 12+ (API 31+) devices
  • Android 11 and below work correctly as they use the drawable/launch_background.xml approach
  • The issue persists even after:
    • Running flutter clean
    • Deleting and recreating the Android folder
    • Uninstalling and reinstalling the app
    • Upgrading to the latest plugin version

Suggested Fix

The plugin should read the color and color_dark values from flutter_native_splash.yaml and update the android:windowSplashScreenBackground property in the Android 12+ style files on every regeneration, not just on initial creation.

Impact

This bug makes it impossible to update splash screen colors on Android 12+ devices without manually editing XML files, which defeats the purpose of using a configuration-based plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions