flutter_native_splash
flutter_native_splash copied to clipboard
Splash Screen Stuck in Android Emulator Tablet
Describe the bug
The app freezes on the native splash screen when installing the application on the Android tablet emulator.
Configuration
flutter_native_splash section of your yaml config.
dependencies:
flutter:
sdk: flutter
components:
path: ../components
app_links: ^3.4.5
flutter_native_splash: ^2.4.4
flutter_smartlook: ^4.1.25
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: ^1.24.3
# flutter_native_splash-development.yaml
flutter_native_splash:
color: "#0077FF"
color_dark: "#0077FF"
image: assets/images/logo.png
android_12:
icon_background_color: "#0077FF"
icon_background_color_dark: "#0077FF"
image: assets/images/splash12.png
web: false
main.dart
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeApp(); // Avoid excessive delays
FlutterNativeSplash.remove();
await Firebase.initializeApp();
WidgetsBinding.instance.addPostFrameCallback((_) {
FlutterNativeSplash.remove();
print("First frame rendered. Splash screen should be gone.");
});
Device (please complete the following information):
- Device: [e.g. ANDROID TABLET 7 inch]
- OS: [e.g. [Android 15] VANILLA_ICE_CREAM]
To Reproduce Steps to reproduce the behavior, using the example app:
-
Set the config on the example app to
-
Run in an emulator configured with
-
See errorScreenshots If applicable, add screenshots to help explain your problem. If in doubt, attach a screenshot.
Already had this issue myself and I realised that you need to call in main:
var widgetBindings = WidgetsFlutterBinding.ensureInitialized(); FlutterNativeSplash.preserve(widgetsBinding: widgetBindings);
and also before the first frame rendered before run app:
FlutterNativeSplash.remove();
The problem was the same as you did I added a postFrameCallback but there is no widget for the callback to subscribes when you add in main therefore it will not called and by this fact the remove won't call at all and the splash will stuck on. Use it without post frame callback and it will be good.