Appearance
⚡ Performance Optimization Standards for Flutter
Table of Contents
Core Standards
Performance Requirements
- Always optimize for 60fps rendering performance
- Minimize widget rebuilds to essential updates only
- Use const constructors wherever possible
- Implement proper memory management to prevent leaks
- Optimize network requests for minimal data transfer
- Use efficient data structures for large datasets
- Implement proper caching strategies for frequently accessed data
- Profile and measure performance regularly
Performance Monitoring Rules
- Use Flutter DevTools for performance profiling
- Monitor frame rendering times and identify bottlenecks
- Track memory usage and detect memory leaks
- Measure app startup time and optimize accordingly
- Monitor network performance and optimize API calls
- Regularly audit performance with real device testing
Performance Areas
Widget Performance
- Use const constructors for static widgets
- Use RepaintBoundary for expensive paint operations
- Use ListView.builder for large lists instead of ListView
- Minimize widget tree depth and complexity
- Use proper widget keys when needed for efficient updates
- Implement proper widget composition to avoid unnecessary rebuilds
- Use AutomaticKeepAliveClientMixin for expensive widgets
- Optimize widget build methods to be as fast as possible
State Management Performance
- Emit states only when necessary to minimize rebuilds
Memory Management
- Always dispose controllers in dispose methods
- Cancel stream subscriptions to prevent memory leaks
- Use proper data structures for memory efficiency
- Minimize object creation in hot paths
Network Performance
- Implement proper request cancellation for unused requests
- Minimize data transfer by sending only necessary data
- Use proper network monitoring for performance tracking
Image and Asset Optimization
- Use CachedNetworkImage for network images
- Use proper image compression for file size optimization when needed
- Use proper video compression for file size optimization when needed
Common Violations
❌ DO NOT Violate These Rules
- Don't use ListView or SingleChildScrollView for large lists - Use ListView.builder instead
- Don't forget const constructors - Always use const for static widgets
- Don't ignore memory leaks - Always dispose controllers and streams
- Don't use expensive operations in build methods - Move to separate methods
- Don't forget RepaintBoundary - Use for expensive paint operations
- Don't use unnecessary rebuilds - Implement proper state management
- Don't ignore performance profiling - Always profile before optimization
- Don't use inefficient data structures - Choose appropriate structures
- Don't forget image optimization - Always optimize images for mobile
- Don't ignore network optimization - Always implement proper caching
- Don't use unnecessary animations - Only animate when necessary
- Don't forget proper disposal - Always dispose resources properly
- Don't use inefficient widgets - Choose appropriate widgets for use case