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.push and MaterialPageRoute instead 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

WrongCorrect
Navigator.push(context, MaterialPageRoute(...))GoRouter with context.go('/path')
if/else chains for stateSealed classes + exhaustive switch
setState for shared stateRiverpod providers
Map<String, dynamic> for grouped dataDart 3 records
Widget() without constconst Widget()
Hardcoded colors/sizesTheme.of(context)
ListView inside ColumnCustomScrollView with slivers
Raw String for entity IDsExtension types
dynamic typeProper types or Object? + pattern matching

License

MIT