Difference Between a Cold Start and a Hot Restart?
Answer
Overview
Cold Start and Hot Restart describe different ways a Flutter app begins running — with major differences in startup speed and what state is preserved.
Cold Start
A Cold Start is when the app launches from scratch — the process is completely fresh.
textDevice → OS launches app process → Flutter engine initializes → Dart VM starts → main() runs → App displays first frame
What happens in a Cold Start:
- ✅ Full app process starts fresh
- ✅ All dependencies initialized
- ✅ All state fully freshly created
- ❌ Slowest — everything is done from zero
- ❌ App data from previous session is not in memory (must be loaded from storage)
When it occurs:
- First app launch after install
- After device reboot
- After the app is force-killed
- After too long in the background (OS killed the process)
dart// In cold start, this runs from the beginning void main() { WidgetsFlutterBinding.ensureInitialized(); // All initialization happens fresh runApp(MyApp()); }
Hot Restart (Flutter Dev Tool)
A Hot Restart is a Flutter development feature that re-runs the app within the existing Dart VM, without restarting the OS process.
textFlutter CLI → Recompiles Dart code → Reinitializes Dart state → Re-executes main() → App rebuilds from scratch (visually)
What happens in a Hot Restart:
- ✅ Dart VM stays alive — faster than cold start
- ✅ Code changes are picked up
- ❌ All Dart state is lost — state, variables resettext
StatefulWidget - ❌ is called againtext
initState() - ✅ Faster than cold start (no OS process init)
bash# Trigger via CLI flutter run # then press 'R' for Hot Restart # Or keyboard shortcut in IDE: Shift+R
Hot Reload vs Hot Restart (Bonus)
| Feature | Hot Reload | Hot Restart |
|---|---|---|
| Speed | Fastest | Fast |
| State preserved | ✅ Yes | ❌ No |
| Code changes | UI/logic (no initState) | All changes |
| main() re-runs | ❌ No | ✅ Yes |
| initState re-runs | ❌ No | ✅ Yes |
Full Comparison
| Aspect | Cold Start | Hot Restart |
|---|---|---|
| OS process | Brand new | Existing |
| Dart VM | Brand new | Existing |
| Dart state | Fresh | Reset |
| Speed | Slowest (~2-5s) | Fast (~1-2s) |
| Available in | Production + Dev | Only Development |
| Use case | Real user experience | Picking up big code changes |
Improving Cold Start Performance
dart// 1. Use const widgets to reduce build time const MyWidget(); // 2. Defer non-critical initialization void main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(MyApp()); // Show UI first // Initialize non-critical things after first frame WidgetsBinding.instance.addPostFrameCallback((_) async { await Analytics.init(); await RemoteConfig.fetch(); }); } // 3. Use AOT compilation for production // flutter build apk --release
Summary: Cold Start = full fresh launch from OS (slowest, production scenario). Hot Restart = re-runs Dart code in existing VM (dev tool, loses all state). Hot Reload = updates UI without re-running anything (fastest, preserves state).