jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.28k stars 200 forks source link

background_image is not working #690

Closed RaulLit closed 1 month ago

RaulLit commented 1 month ago

Describe the bug After setting the background_image: property and creating the splash screen using dart run flutter_native_splash:create I could only see a black screen instead of my background image while launching the app. I've mentioned all the steps I took in detail below in the To Reproduce section.

Configuration When I installed flutter_native_splash using flutter pub add flutter_native_splash the following message appeared

Because every version of flutter_test from sdk depends on path 1.8.3 and flutter_native_splash >=2.3.12 depends on path ^1.9.0, flutter_test from sdk is incompatible with flutter_native_splash >=2.3.12.
So, because my_new_application depends on both flutter_native_splash ^2.4.0 and flutter_test from sdk, version solving failed.

You can try the following suggestion to make the pubspec resolve:
* Consider downgrading your constraint on flutter_native_splash: flutter pub add flutter_native_splash:^2.3.10

Following is my pubspec.yaml file:

dependencies: 
  flutter_native_splash: ^2.3.10
flutter_native_splash:
  background_image: "assets/images/img_splash.png"
  android_12:
    background_image: "assets/images/img_splash.png"
  web: false
  android: true
  ios: true
flutter: 
  uses-material-design: true
  assets: 
    - assets/
    - assets/images/

Device:

To Reproduce Steps to reproduce the behavior, using the example app:

  1. I uploaded an image img_splash.png under assets/image folder.
  2. Updated the pubspec.yaml file as mentioned above.
  3. Opened a terminal in the root project folder. Then executed the following commands one by one.
    • flutter clean
    • flutter pub get
    • dart run flutter_native_splash:create
    • flutter run
  4. After the app launched I could only see black screen and not the background image I wanted.

Addition Information I tried setting the following afterwards

android_gravity: fill

still didn't work

RaulLit commented 1 month ago

After updating pubspec.yaml file as follows:

flutter_native_splash:
  color: "#F06610"
  image: assets/images/img_splash.png
  color_dark: "#F06610"
  image_dark: assets/images/img_splash.png
  android_gravity: fill
  ios_content_mode: scaleAspectFill
  android_12:
    color: "#F06610"
    image: assets/images/img_splash.png
    color_dark: "#F06610"
    image_dark: assets/images/img_splash.png
    android_gravity: fill
  web: false
  android: true
  ios: true

I get this as the splash screen image

I want my img_splash.png file to take up the entire screen.

jonbhanson commented 1 month ago

As stated in the readme, Android 12 does not support a background image.

RaulLit commented 1 month ago

Ahh... Right. An overlook from my side. Thank you @jonbhanson