Don't make a Flutter splash. Let the native iOS/Android splash fill the screen while the Flutter app's main
code decides to show the Home or Login page. It should be a very quick process if all you are doing is looking in SharedPreferences
for a session token.
I just answered two other questions today that deal with this very same issue. It think they should help...
https://stackoverflow.com/a/60121967/7034640
https://stackoverflow.com/a/60122485/7034640
UPDATE
I created a Flutter test app.
I set the Android splash screen to be red.
I changed the contents of main.dart
to the following.
import 'package:flutter/material.dart';
void main() async {
await Future.delayed(Duration(seconds: 5));
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(final BuildContext context) {
return MaterialApp(
title: 'Splash Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(final BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("My Home Page")),
body: Center(child: const Text("My Home Page")),
);
}
}
I ran the app on an Android device with flutter run --release
.
I see the red screen for about 0.5 seconds, then see a black screen for 5 seconds, and finally see the home screen.
Hmm. I expected the red screen to show for about 5.5 seconds and then the home screen. I did not expect the black screen to show.