skip to Main Content

Using the flutter_native_splash 2.3.2 lib, I’m defining a custom splash screen for my app. However, when sending to the requester, who uses Android 10, the initial presentation screen only shows the background and does not present the icon correctly. What should I do? I’ve looked elsewhere and haven’t found a solution.

Here is the pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  flutter_inappwebview: ^5.7.2+3
  flutter_native_splash: ^2.3.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.13.1

flutter_icons:
  android: true
  ios: true
  image_path: "images/adecop-logo.png"

flutter_native_splash:
  color: "##1e1b3a"
  android: true
  ios: false
  fullscreen: true
  icon: "images/adecop-logo.png"
  android_12:
    icon_backgroound_color: "##1e1b3a"

My main.dart

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();

  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);

  await Future.delayed(Duration(seconds: 1));

  FlutterNativeSplash.remove();

  runApp(const HomePage());
}

I tried to change some XML settings, looking at the Android documentation, but I didn’t find it very clear and I tried several other solutions pointed out on the internet, videos on youtube, but none with success.

2

Answers


  1. Try adding this line in Manifest

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

    Login or Signup to reply.
  2. 1.step—-> paste your image this path (…androidappsrcmainresdrawable)

    2.step—-> …androidappsrcmainresdrawablelaunch_background.xml
    my image name :logo_final you can change your image name this part of code

    <?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/white" />
    
        <!-- You can insert your own image assets here -->
           <item>
            <bitmap
                android:gravity="center"
                android:src="@drawable/logo_final" />
        <!-- logo_final is asset image for splash screen -->
        </item>
    </layer-list>
    
    1. step your styles.xml need to delete normaltheme part and add like that

    …… androidappsrcmainresvaluesstyles.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
        <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
            <!-- Show a splash screen on the activity. Automatically removed when
                 the Flutter engine draws its first frame -->
            <item name="android:windowSplashScreenAnimatedIcon" >@drawable/logo_final</item>
                <item name="android:windowFullscreen">true</item>
    
        </style>
        <!-- Theme applied to the Android Window as soon as the process has started.
             This theme determines the color of the Android Window while your
             Flutter UI initializes, as well as behind your Flutter UI while its
             running.
    
             This Theme is only used starting with V2 of Flutter's Android embedding. -->
    </resources>
    

    and also now we have a some problem about resize splash screen photo if i will find i will share 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search