ISSUE: Flutter native splash is showing only the background when launched right after installing with APK (first launch). But when later opened the, the main image and branding is shown. When installing directly from VS Code to physical or virtual device, the logo and the branding is displayed.
What I want: When the app is first installed and launched, the splash screen should display a logo in the middle and a branding logo at the bottom.
What I have tried:
Since I was using a separate .yaml file for the splash screen, as per some tutorials and the documentation, I used the following commands in my project directory:
flutter clean
flutter pub get
dart run flutter_native_splash:create --path=native_splash.yaml
Since the issue was still there I tried shifting everything from my native_splash.yaml to my pubspec.yaml and it made no changes.
The following are my codes.
main.dart
void main() async {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
await Future.delayed(
const Duration(seconds: 3),
);
FlutterNativeSplash.remove();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
return GetMaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: AppRoute.homeScreen,
getPages: PageScervice.list,
);
}
}
native_splash.yaml
flutter_native_splash:
color: "#BBDEFB"
image: "assets/logo-main.png"
branding: "assets/logo-branding.png"
android: true
ios: true
web: false
android_12:
color: "#BBDEFB"
image: "assets/logo-main.png"
branding: "assets/logo-branding.png"
icon_background_color: "#BBDEFB"
fullscreen: true
styles.xml
I also want to mention that logo_main.png is 500px X 500px.