Reputation: 304
I am using flutter_launcher_icons: ^0.9.3 as following to change the app icon and it is working perfectly
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/logo.png"
now I want to use flutter_native_splash: ^2.1.6 to adjust my splash screen. I used the following:
pubspec:
flutter_native_splash:
color: "#42a5f5"
image: assets/launch_image.png
android: true
ios: true
Main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
await Firebase.initializeApp();
runApp(const MyApp());
}
problem is application always display the flutter_launcher_icon (logo.png) as splash screen, not the flutter_native_splash one (launcher_image). where is the problem?
Note: I removed icon luncher package. now it is using default Flutter icon as Splah icon! .. I checked res directoy, I can find my correct image listed in new folders Dwaralble-hdpi .. etc with name of SPLASH. but it is not effective at all.
Upvotes: 5
Views: 13476
Reputation: 191
From the flutter_native_splash documentation:
Android 12 handles the splash screen differently than previous versions. Please visit https://developer.android.com/guide/topics/ui/splash-screen. Following are Android 12 specific parameter.
android_12: # The image parameter sets the splash screen icon image. If this parameter is not specified, # the app's launcher icon will be used instead.
So the problem is you need to set the android_12 parameter aswell as the image parameter, and then also set an image parameter inside. Like so:
pubspec.yaml:
flutter_native_splash:
color: "#42a5f5"
image: assets/launch_image.png
android_12:
image: assets/launch_image.png
android: true
ios: true
Assuming you have your path pointing to the right image file, it should now correctly display in the center of the screen.
Upvotes: 19