Sub topic 13
Perceived startup: native splash and first screen design
Earlier chapters measured and shortened the real startup path. This chapter covers what the user sees while that path runs. Two apps with the same time to first frame can feel very different, depending on what is on screen during the wait and what appears first.
This chapter assumes you have read the chapters on startup phases, --trace-startup, and keeping main() lean. It also assumes you can edit Android resource files and open the iOS project in Xcode.
Real time and perceived time
Time to first frame is a number you can measure. Perceived startup is how long the wait feels. Three things shape it:
- Continuity. If the screen changes from launch image to a different color to a blank frame to the real UI, users notice each jump as a flicker. A stable color or image from tap to first screen feels shorter.
- Meaningful content. A screen with structure (header, list outlines) feels faster than a spinner on white, even when both arrive at the same time.
- Responsiveness. If the first frame appears but taps do nothing for a second, the app feels broken. That is worse than a longer splash.
Perceived-startup work does not replace the optimizations from earlier chapters. It hides the part you cannot remove, such as engine start-up, and it keeps you from making the remaining wait feel longer than it is.
The native splash is drawn by the operating system before any Dart code exists. You cannot draw it with widgets. You configure it in each platform's project.
The native splash on each platform
The splash is part of the platform project, so Android and iOS need separate setup.
| Platform | Where it lives | What you control |
|---|---|---|
| Android 12 and later | `values-v31/styles.xml` in the launch theme | Background color, one icon, optional icon background |
| Android 11 and earlier | `drawable/launch_background.xml` | A layer list with a color and an optional bitmap |
| iOS | `LaunchScreen.storyboard` | Any storyboard layout: color, image, constraints |
Android
A new Flutter project defines a LaunchTheme that the activity uses at start, and a NormalTheme that replaces it once Flutter is ready. For older Android versions you edit launch_background.xml. For Android 12 and later (API 31) the system draws the splash from theme attributes and ignores most of windowBackground. Add a values-v31 override.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowSplashScreenBackground">#0B1F3A</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
</style>
</resources>Place this in android/app/src/main/res/values-v31/styles.xml. If you add a night variant in values-night-v31, a dark-mode user will not get a white flash.
Android 12 and later limits what the splash can show. It shows one icon on a solid color. A full-screen illustration is not possible, and the system crops the icon to a circle mask. Keep the artwork inside the safe area: about a 192 dp circle inside a 288 dp canvas when there is no icon background, or 160 dp inside 240 dp with one. Artwork that fills the canvas gets clipped.
iOS
iOS shows LaunchScreen.storyboard until the app starts. Flutter then keeps showing the same launch screen inside its view until the first frame is rendered. So the storyboard covers both the OS phase and the engine-start phase. Open ios/Runner.xcworkspace, edit the storyboard, and set the background color to match your first screen.
iOS caches launch screens aggressively. If a change does not show, delete the app from the device or simulator and reinstall it.
Packages that generate this for you
The flutter_native_splash package reads a configuration block in pubspec.yaml and writes the Android and iOS files. It saves time and handles dark mode and the Android 12 rules. It is still a third-party dependency that edits native files, so review the diff it produces and re-run it after changing the configuration. A hand-written splash for one color and one logo takes about ten minutes and has no dependency.
Match the first frame to the splash
The most common perceived-startup bug is a visible seam between the splash and the first Flutter frame. Check these:
- Background color. If the splash is dark navy and your
Scaffoldis white for one frame, the user sees a flash. Use the same color value in both places. - Logo position. If the splash logo is centered and your first screen puts it at the top, it appears to jump. Either keep it centered during the transition or do not repeat it.
- Status bar and system UI. A different status bar style between splash and first screen shifts the layout slightly.
- Theme mode. Make sure a dark-mode device gets a dark splash and a dark first frame. Read the platform brightness for your initial
ThemeMode.
Designing the first screen
The first screen should render from data that is already in memory, then fill in the rest. This follows from the previous chapter: whatever main() awaits before runApp adds directly to the splash time. A network call placed there turns a 400 ms launch into a multi-second one on a poor connection.
Use these rules for the first screen:
- Build it from local state only. Layout, text, and static images need no waiting.
- Show a placeholder (a skeleton) for content that needs I/O, and replace it when the data arrives.
- Show cached data first when you have it, then refresh in the background.
- Defer anything not visible on the first screen: other tabs, dialogs, large lists below the fold.
- Handle failure in the placeholder state. A first screen that can only show a spinner has no way to report an error.
This example renders the page structure immediately and loads data afterwards. It runs as written.
import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF0B1F3A)),
scaffoldBackgroundColor: const Color(0xFF0B1F3A),
),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
late final Future<List<String>> _items = _loadItems();
Future<List<String>> _loadItems() async {
// Stands in for a network or database call.
await Future<void>.delayed(const Duration(milliseconds: 800));
return List.generate(5, (i) => 'Item ${i + 1}');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Inbox')),
body: FutureBuilder<List<String>>(
future: _items,
builder: (context, snapshot) {
if (snapshot.hasError) {
return const Center(child: Text('Could not load items'));
}
final items = snapshot.data;
return ListView.builder(
itemCount: items?.length ?? 5,
itemBuilder: (context, index) {
if (items == null) {
return const ListTile(
title: SizedBox(
height: 16,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white24),
),
),
);
}
return ListTile(title: Text(items[index]));
},
);
},
),
);
}
}The scaffold color matches the Android splash color above, so the handoff has no flash. The app bar and list outline appear in the first frame. The data arrives 800 ms later and replaces the placeholders in place, with no layout shift.
Images and fonts on the first screen
Large images are a hidden cost. An image that decodes during the first frame can make that frame slow, and one that decodes after it pops in visibly. Options:
- Use a smaller asset, or one sized for the display, for anything on the first screen.
- Call
precacheImagefor an important image once you have aBuildContext, for example indidChangeDependencies, so it is decoded before it is needed. - Avoid loading fonts from the network on the first screen. Bundled fonts avoid a swap from fallback to final font.
Holding the splash longer
flutter_native_splash can keep the native splash on screen until you call FlutterNativeSplash.remove(). This is useful when a short, required step must finish before the first screen makes sense, such as reading the saved login state to choose between a sign-in page and a home page.
Use it sparingly.
- It hides the delay without shortening it. Total time to a usable screen is unchanged, and the user cannot see progress.
- Add a timeout. If the awaited step hangs, the user stares at the splash forever. Remove the splash after a fixed limit and show an error or fallback.
- Keep the step local. Reading a small value from local storage is acceptable. A network request is not.
An alternative that needs no package is to render a first frame that looks like the splash (same color, same logo) and swap to the real content when the state is known. That keeps the app responsive and puts the wait in your own code, where you can add a timeout and a retry button.
Common mistakes
- Fake delays. A deliberate two-second splash for branding adds two seconds to every launch. The platform splash already shows your brand while the app genuinely starts.
- A Dart splash screen after a native one. Showing a second splash widget while the app waits for nothing adds a second transition. Do real work or go straight to content.
- Animated splashes on Android 12 and later. The animated icon is limited to a short duration, and the system may skip it. Do not tie required work to it.
- Testing only in debug. Debug builds take much longer to start, so the splash is on screen for a long time and the transition looks different. Judge the handoff in profile or release mode on a real device.
- Testing only on a fast device. The seam between splash and first frame is invisible when the gap is 50 ms. Test on a low-end device, where the gap may last a second.
Summary of the approach
- Set the native splash color and logo on both platforms, including dark mode and Android 12 and later.
- Use the same background color in your theme so the handoff has no flash.
- Render the first screen from local data, with placeholders for anything that needs I/O.
- Keep large images and network-dependent fonts off the first frame.
- Only extend the splash for a short local step, and always give it a timeout.
- Check the result in profile or release mode on a slow device.
Exercise
Your Flutter app starts with a dark navy native splash, but users see a brief white flash just before the home screen appears. The home screen's Scaffold uses the default theme. What is the likely cause, and what is the fix?
Show answer
The first Flutter frame paints the default light scaffold background, which differs from the navy splash, so one frame shows white. Set the same color in the theme (for example scaffoldBackgroundColor) and make sure dark mode uses a matching dark splash and theme.
Exercise
A teammate adds await fetchRemoteConfig() before runApp and uses FlutterNativeSplash.preserve to keep the splash up until it finishes. Launch now feels fine on Wi-Fi. Name two problems with this design and one alternative.
Show answer
First, on a slow or offline connection the splash stays up for as long as the request takes, and with no timeout it could hang indefinitely. Second, the delay is hidden but not removed, so time to a usable screen grew. Alternative: render the first screen from cached or default values immediately, and fetch the remote config after the first frame, updating the UI when it arrives.
Exercise
Why can a full-screen illustration in an Android 12 splash end up cropped or ignored, and what should you design instead?
Show answer
Android 12 and later draws the splash from theme attributes: one icon on a solid background color, masked to a circle. Artwork outside the safe area is clipped, and a full-screen image is not supported. Design a simple icon that fits inside the safe circle, and set the background color to match your first screen.