Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 942
Dev Chauhan Avatar asked Sep 18 '21 05:09

Dev Chauhan


People also ask

How do I add a splash screen in flutter?

To do so, open the Flutter app's Xcode project by typing open ios/Runner. xcworkspace from the root of your app directory. Then select Runner/Assets. xcassets from the Project Navigator and drop in the desired images to the LaunchImage image set.

How do I get rid of splash screen in flutter?

Set up app initialization (optional) By default, the splash screen will be removed when Flutter has drawn the first frame.

What is Splashscreen in flutter?

A splash screen is a launch screen, start screen, or boot screen, which is a graphical control element containing the image, logo, and current version of the software. It is the first screen of the app that displays whenever the application is loading.


1 Answers

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

like image 148
Kishan Dhankecha Avatar answered Nov 15 '22 00:11

Kishan Dhankecha