This guide provides everything you need to build high-performance Flutter applications and plugins. All recommendations are based on modern Flutter best practices and real-world performance metrics.
- SKILL.md - Comprehensive 1,983-line performance optimization guide with 10 major topics
- PERFORMANCE_GUIDE.md - This file (quick reference and roadmap)
Why It Matters: Reduces compile time and app startup latency.
Key Techniques:
- AOT Compilation & Obfuscation
- Incremental Build Optimization
- Modular Architecture with Feature Modules
- Gradle Performance Configuration
- Split APK Building
Quick Start:
flutter build apk --split-per-abi --obfuscate --split-debug-info=build/app/outputs/mappingTarget: <2 second startup time
Why It Matters: Ensures smooth 60+ FPS for better user experience.
Key Techniques:
- Frame Rate Consistency (60 FPS standard, 120 FPS premium)
- RepaintBoundary for rendering isolation
- Const Widget Constructors
- State Management Optimization (Provider, Riverpod)
- Scrolling Performance Optimization
Anti-Patterns to Avoid:
- Heavy computations in build()
- Unnecessary widget rebuilds
- Unoptimized state listeners
Target: Consistent 60 FPS (16.67ms per frame)
Why It Matters: Prevents crashes on low-end devices and reduces battery drain.
Key Techniques:
- Memory Profiling with DevTools
- Image Cache Configuration
- Network Image Caching
- Resource Cleanup in dispose()
- Memory Leak Prevention
Best Practices:
- Always cancel StreamSubscriptions
- Dispose Timers in dispose()
- Use WeakReferences for callbacks
- Monitor mounted flag before setState()
Target: <100 MB average memory usage
Why It Matters: Smaller download size and faster app load times.
Key Techniques:
- Dependency Auditing
- Asset Bundle Optimization
- Selective Font Loading
- Lazy Asset Loading
Audit Commands:
flutter pub deps --compact
flutter pub outdated
flutter analyze --verboseTarget: <50 MB APK/IPA
Why It Matters: Reduces initial app size for faster first launch.
Key Techniques:
- Feature Module Architecture
- Deferred Imports
- Conditional Compilation
- Progressive Feature Loading
Benefits:
- Reduced initial APK size
- On-demand feature loading
- Better app distribution
- Faster time-to-interactive
Why It Matters: Images consume 50-80% of app size; optimization has massive impact.
Key Techniques:
- Image Compression & Format Selection
- WebP Conversion (30% smaller than JPEG)
- Responsive Images with Resolution Variants
- Network Image Caching
- SVG for Icons (vector graphics)
Image Size Recommendations:
- Icons: SVG format
- Photos: WebP or HEIC
- Thumbnails: Max 400x400px
- High-res: Multiple variants (@1x, @2x, @3x)
Target: 50% size reduction through format optimization
Why It Matters: 50% of app slowness is network-related.
Key Techniques:
- HTTP/HTTPS Connection Pooling
- Request Caching Strategies
- Data Compression (gzip)
- Offline Queue for Resilience
- Connectivity Monitoring
Caching Strategy:
// Cache API responses for 1 hour
await fetchCached(url, cacheDuration: Duration(hours: 1));Target: <500ms average latency, 95% cache hit rate
Why It Matters: Users judge apps by battery impact.
Key Techniques:
- Compute Isolation for Heavy Operations
- Stream Throttling & Debouncing
- Background Task Scheduling
- Battery-Aware UI Adaptation
- Event Handler Optimization
Battery Monitoring:
final powerSaveMode = await BatteryAwareBehavior().shouldEnablePowerMode();
if (powerSaveMode) {
// Reduce frame rate or disable animations
}Target: <5% battery drain per hour
Why It Matters: Can't optimize what you don't measure.
Key Tools:
- Performance Profiler
- FPS Monitor
- Memory Profiler
- DevTools Integration
- Timeline Events
Essential Commands:
flutter run --profile
# Open DevTools in browser -> Performance tabWhy It Matters: Every MB matters for adoption and install rates.
Key Techniques:
- R8/ProGuard Configuration
- Split APKs by Architecture
- Native Library Optimization
- Bitcode for iOS
- Bundle Size Analysis
Size Reduction Checklist:
- Enable code minification:
minifyEnabled true - Enable resource shrinking:
shrinkResources true - Use split APKs:
--split-per-abi - Compress assets to WebP
- Remove debug symbols:
--split-debug-info
| Metric | Target | Critical | Priority |
|---|---|---|---|
| App Startup | <2s | <3s | P0 |
| Time to Interactive | <5s | <7s | P0 |
| Frame Rate (avg) | 60 FPS | >45 FPS | P0 |
| Jank (frame drops) | <5% | <10% | P0 |
| Memory (avg) | <100 MB | <150 MB | P1 |
| Memory (peak) | <200 MB | <250 MB | P1 |
| APK/IPA Size | <50 MB | <100 MB | P1 |
| Network Latency | <500ms | <1000ms | P1 |
| Battery Impact | <5%/hour | <10%/hour | P2 |
| Cache Hit Rate | >95% | >80% | P2 |
- Enable code obfuscation and minification
- Configure image caching and compression
- Implement memory leak prevention patterns
- Add DevTools performance monitoring
- Audit and optimize dependencies
- Implement state management best practices
- Optimize rendering with RepaintBoundary
- Add network request caching
- Implement offline support queue
- Set up battery-aware behavior
- Implement feature module architecture
- Add deferred imports for large features
- Configure background task scheduling
- Implement custom profiling
- Optimize APK/IPA for distribution
- Set up performance dashboards
- Monitor real user metrics (RUM)
- Establish performance budgets
- Regular profiling and optimization cycles
- Benchmark against competitors
class SafeWidget extends StatefulWidget {
@override
State<SafeWidget> createState() => _SafeWidgetState();
}
class _SafeWidgetState extends State<SafeWidget> {
late StreamSubscription _sub;
@override
void initState() {
super.initState();
_sub = stream.listen((_) {
if (mounted) setState(() {}); // Check mounted
});
}
@override
void dispose() {
_sub.cancel(); // Always cleanup
super.dispose();
}
@override
Widget build(BuildContext context) => Container();
}ListView.builder(
addAutomaticKeepAlives: true,
cacheExtent: 250.0,
itemCount: 1000,
itemBuilder: (context, index) {
return RepaintBoundary(
child: ListTile(title: Text('Item $index')),
);
},
)final optimizedStream = ComputeOptimizer.debounce(
searchStream,
const Duration(milliseconds: 300),
);await CompressionManager.compressedPost(
Uri.parse('https://api.example.com/data'),
{'key': 'value'},
);# Profile mode (closest to release)
flutter run --profile
# Trace frame rendering
flutter run --profile --trace-startup
# Memory profiling
flutter run --profile
# Open DevTools -> Memory tab# On low-end device
flutter run --release -d <device_id>
# Monitor frame drops
flutter run --profile
# DevTools -> Performance -> Frame Analysis# .github/workflows/performance.yml
- name: Performance Tests
run: |
flutter test --profile
flutter build apk --release
# Check APK size
du -h build/app/outputs/flutter-app.apkProblem: Provider/Consumer rebuilds entire subtree
Solution: Use select() for fine-grained updates
// BAD: Full rebuild
Consumer<UserProvider>(
builder: (_, provider, __) => Text(provider.name),
)
// GOOD: Only rebuild when name changes
Consumer<UserProvider>(
builder: (_, provider, __) => Text(provider.name),
child: Consumer<UserProvider>(
builder: (_, counter, __) => Text('${counter.count}'),
),
)Problem: Freezes UI during data processing Solution: Offload to isolate
// BAD
final result = heavyComputation(data);
// GOOD
final result = await compute(heavyComputation, data);Problem: Memory leak, continuous processing Solution: Always cancel in dispose()
@override
void dispose() {
_subscription.cancel();
_timer.cancel();
super.dispose();
}Problem: 80% of app size Solution: Use WebP, compress, provide variants
ffmpeg -i image.png -c:v libwebp -quality 85 image.webp- App Startup Time - Time from launch to first UI render
- First Meaningful Paint - Time when core content is visible
- Time to Interactive - When user can interact with app
- Frame Rate - FPS during scrolling and animations
- Memory Usage - RAM consumption over time
- APK/IPA Size - Final distribution size
- Network Latency - API response times
- Battery Drain - mAh consumed per hour
- Crash Rate - OOM and other crashes
- User Complaints - App store ratings related to performance
- Industry-Leading Performance: 60 FPS consistent, sub-2s startup
- Lightweight: <50 MB APK/IPA for premium experience
- Battery Efficient: <5% per hour on standby, <15% during active use
- Network Smart: Works offline, syncs when connected
- Responsive: <500ms latency for all operations
- Smooth Experience: Zero jank on modern and legacy devices
- Flutter Performance: https://flutter.dev/docs/testing/ui-performance
- DevTools Performance: https://dart.dev/tools/dart-devtools
- Build Optimization: https://flutter.dev/docs/deployment/ios/release-build-ios
- Flutter Performance Monitoring
- Google Performance Best Practices
- Platform-Specific Optimization Guides
- Review SKILL.md for detailed implementations
- Measure current performance using DevTools
- Identify bottlenecks with profiling
- Implement optimizations from high to low priority
- Validate improvements with benchmarks
- Monitor production with analytics
- Iterate based on user feedback
For detailed code examples and implementations, refer to SKILL.md which contains:
- 50+ code examples
- Implementation patterns
- Configuration templates
- Best practices checklist
- Performance metrics reference
Last Updated: 2025-11-18 Version: 1.0.0 Status: Ready for Production