Flutter Best Practices
February 21, 2026 · View on GitHub
Modern Flutter and Dart 3 patterns — stop agents from generating deprecated Navigator 1.0, StatefulWidget-heavy, and pre-Dart 3 code.
Why This Plugin?
AI agents are trained on data that includes outdated Flutter patterns. This plugin ensures your agent uses current best practices. Agents commonly get these wrong:
- Navigator 1.0 — Using
Navigator.pushandMaterialPageRouteinstead of GoRouter - Pre-Dart 3 patterns — Long if/else chains instead of sealed classes, Map/dynamic instead of records
- StatefulWidget overuse — setState everywhere instead of Riverpod or proper state management
- Missing const — Widgets that could be const are not, increasing rebuild cost
- Hardcoded styling — Colors and sizes instead of Theme.of(context)
- Nested scrollables — ListView inside Column causing unbounded height errors
Install
Cursor IDE
/add-plugin flutter-best-practices
Claude Code
/plugin install flutter-best-practices
Skills only (any agent)
npx skills add ofershap/flutter-best-practices
Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.
What's Included
Skills
- flutter-best-practices — Modern Flutter and Dart 3 patterns with Wrong vs Correct code examples
Rules
- best-practices — Always-on rules that enforce GoRouter, Dart 3 features, Riverpod, const constructors, and theme usage
Commands
/audit— Scan your codebase for Flutter anti-patterns (Navigator 1.0, setState misuse, missing const, etc.)
Key Patterns This Plugin Fixes
| Wrong | Correct |
|---|---|
Navigator.push(context, MaterialPageRoute(...)) | GoRouter with context.go('/path') |
| if/else chains for state | Sealed classes + exhaustive switch |
setState for shared state | Riverpod providers |
Map<String, dynamic> for grouped data | Dart 3 records |
Widget() without const | const Widget() |
| Hardcoded colors/sizes | Theme.of(context) |
| ListView inside Column | CustomScrollView with slivers |
| Raw String for entity IDs | Extension types |
dynamic type | Proper types or Object? + pattern matching |
License
MIT