Minimize cold-start time for the Flutter app on Android emulator.
Target metric: startup_ms (lower is better)
Run command: flutter test integration_test/startup_bench.dart --plain-name "startup" 2>&1 | grep "startup_ms"
Time budget: 3 minutes per experiment
Only these files may be modified during experiments:
lib/main.dart— App entry point, initialization sequence, provider setuplib/app.dart— Root widget, route configuration, theme setuplib/di/injection.dart— Dependency injection setup, service registration order
integration_test/— Benchmark harnesspubspec.yaml— Dependencies are lockedlib/models/— Data modelslib/services/— Service layer (only DI registration order can change)
After each run, determine success by:
- The integration test prints
startup_ms: Nto stdout - Extract N as the target metric
- Run 3 times and take the median to reduce variance
Minimum improvement threshold: 20ms Simplicity rule: A 10ms improvement that makes the code unreadable is NOT worth it.
- Do NOT add or remove packages
- Do NOT change the app's functionality
- All screens must still be reachable
- State management pattern must stay the same
- Defer heavy service initialization (lazy singletons)
- Reduce widget tree depth in initial route
- Lazy-load routes that aren't shown on startup
- Move image precaching to post-first-frame callback
- Reduce number of ChangeNotifier rebuilds during init
- Use const constructors where possible
- Removing features to speed up startup
- Switching state management library
- Platform-specific native code changes