Skip to content

Modern Flutter and Dart 3 patterns — stop agents from generating deprecated Navigator 1.0, StatefulWidget-heavy, and pre-Dart 3 code

License

Notifications You must be signed in to change notification settings

ofershap/flutter-best-practices

Repository files navigation

Flutter Best Practices

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

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

About

Modern Flutter and Dart 3 patterns — stop agents from generating deprecated Navigator 1.0, StatefulWidget-heavy, and pre-Dart 3 code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors 2

  •  
  •