Agent Skill
2/7/2026flutter-best-practices
Flutter performance optimization guidelines. This skill should be used when writing, reviewing, or refactoring Flutter/Dart code to ensure optimal performance patterns. Triggers on tasks involving Flutter widgets, state management, list rendering, image optimization, animations, or app performance improvements.
K
kaelen
0GitHub Stars
1Views
npx skills add kaelen-hou/flutter-best-practices
SKILL.md
| Name | flutter-best-practices |
| Description | Flutter performance optimization guidelines. This skill should be used when writing, reviewing, or refactoring Flutter/Dart code to ensure optimal performance patterns. Triggers on tasks involving Flutter widgets, state management, list rendering, image optimization, animations, or app performance improvements. |
name: flutter-best-practices description: Flutter performance optimization guidelines. This skill should be used when writing, reviewing, or refactoring Flutter/Dart code to ensure optimal performance patterns. Triggers on tasks involving Flutter widgets, state management, list rendering, image optimization, animations, or app performance improvements.
Flutter Best Practices
Comprehensive performance optimization guide for Flutter applications. Contains 40+ rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new Flutter widgets or screens
- Implementing list rendering (ListView, GridView)
- Optimizing widget builds and state management
- Reviewing code for performance issues
- Refactoring existing Flutter/Dart code
- Setting up navigation with GoRouter
- Reducing app size or improving startup time
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Widget Build Optimization | CRITICAL | build- |
| 2 | List & Scroll Performance | CRITICAL | list- |
| 3 | State Management | HIGH | state- |
| 4 | Image & Asset Optimization | HIGH | image- |
| 5 | Animation Performance | MEDIUM | anim- |
| 6 | Navigation & Routing | MEDIUM | nav- |
| 7 | Memory Management | MEDIUM | memory- |
| 8 | App Size & Startup | LOW-MEDIUM | app- |
Quick Reference
1. Widget Build Optimization (CRITICAL)
build-const-widgets- Use const constructors for static widgetsbuild-split-widgets- Split large widgets into smaller onesbuild-avoid-rebuild- Avoid unnecessary widget rebuildsbuild-keys- Use keys correctly for widget identitybuild-repaint-boundary- Isolate expensive paint operationsbuild-builder-pattern- Use Builder pattern for context access
2. List & Scroll Performance (CRITICAL)
list-builder- Use ListView.builder for large listslist-item-extent- Specify itemExtent for fixed-height itemslist-cache-extent- Configure cacheExtent appropriatelylist-sliver- Use Slivers for complex scrolling layoutslist-keep-alive- Use AutomaticKeepAliveClientMixin wiselylist-separated- Use ListView.separated for dividers
3. State Management (HIGH)
state-provider- Use Provider/Riverpod for dependency injectionstate-selector- Use Selector/select for granular rebuildsstate-notifier- Prefer ValueNotifier for simple statestate-inherited- Understand InheritedWidget properlystate-bloc-events- Structure BLoC events correctlystate-immutable- Keep state objects immutable
4. Image & Asset Optimization (HIGH)
image-cached- Use cached_network_image for remote imagesimage-precache- Precache images for smooth displayimage-resize- Load images at display sizeimage-placeholder- Use placeholders and error widgetsimage-format- Use WebP format for smaller sizesimage-memory- Dispose image resources properly
5. Animation Performance (MEDIUM)
anim-implicit- Prefer implicit animations when possibleanim-ticker- Use TickerProviderStateMixin correctlyanim-transform- Use Transform instead of Containeranim-opacity- Use AnimatedOpacity for fade effectsanim-hero- Implement Hero animations properlyanim-custom-painter- Optimize CustomPainter repaints
6. Navigation & Routing (MEDIUM)
nav-go-router- Use GoRouter for declarative routingnav-deep-links- Configure deep linking properlynav-transitions- Customize page transitionsnav-nested- Handle nested navigation correctlynav-guards- Implement route guards for auth
7. Memory Management (MEDIUM)
memory-dispose- Always dispose controllers and streamsmemory-listeners- Remove listeners on disposememory-isolates- Use isolates for heavy computationmemory-weak-refs- Use WeakReference for caches
8. App Size & Startup (LOW-MEDIUM)
app-tree-shake- Enable icon tree shakingapp-deferred- Use deferred loading for featuresapp-split-debug- Split debug info for smaller buildsapp-obfuscate- Obfuscate Dart code in releaseapp-native-splash- Configure native splash screen
How to Use
Read individual rule files for detailed explanations and code examples:
rules/build-const-widgets.md
rules/list-builder.md
rules/_sections.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
Skills Info
Original Name:flutter-best-practicesAuthor:kaelen
Download