Dev Chauhan
Dev Chauhan

Reputation: 571

Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated

I am new to flutter and recently tried to develop a test app for learning sake with latest version Flutter 2.5. By looking at some tutorial online, I have added flutter_native_splash: ^1.2.3 package for splash screen. And works fine.

However, when I launch app for the first time, it shows following debug message

W/FlutterActivityAndFragmentDelegate(18569): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.

After visiting the above link, I am not able to understand much what is supposed to be done.

Code in pubspec.yaml

flutter_native_splash:
  color: "#FFFFFF"
  color_dark: "#000000"
  image: assets/images/splash_720.png
  android: true
  ios: true
  android12: true

Also, compileSdkVersion and targetSdkVersion is set to 31 in build.gradle

Please help. Thanks in advance.

Upvotes: 12

Views: 11808

Answers (2)

Kishan Dhankecha
Kishan Dhankecha

Reputation: 1015

To avoid that warning you just need to remove that API usage from your project.

Remove these lines of code from the AndroidManifest.xml file.

Remove these lines of code

Previously, Android Flutter apps would either set io.flutter.embedding.android.SplashScreenDrawable in their application manifest, or implement provideSplashScreen within their Flutter Activity. This would be shown momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This is no longer needed and is deprecated – Flutter now automatically keeps the Android launch screen displayed until Flutter has drawn the first frame. Developers should instead remove the usage of these APIs. - source



UPDATE (FLUTTER 2.8.0)

As per the flutter 2.8.0 update, The newly created project doesn't have this warning.

They removed unused API from Androidmanifest.yml but still have belove mentioned code.

They still have these lines of code

Upvotes: 28

Hardik Hirpara
Hardik Hirpara

Reputation: 3046

Remove the below lines from the android manifest file. It's no longer used

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

Upvotes: 4

Related Questions