Agent skill · affaan-m
dart-flutter-patterns
Production-ready Dart and Flutter patterns covering null safety, immutable state with Freezed, async composition, widget architecture, state management (BLoC, Riverpod, Provider), GoRouter navigation with auth guards, Dio networking, error handling, and testing. Use when writing or reviewing Dart and Flutter code — state, widgets, navigation, networking, or architecture.
What it needs
About 7k tokens when loaded.
What this skill does
Dart/Flutter Patterns When to Use Use this skill when: Starting a new Flutter feature and need idiomatic patterns for state management, navigation, or data access Reviewing or writing Dart code and need guidance on null safety, sealed types, or async composition Setting up a new Flutter project and choosing between BLoC, Riverpod, or Provider Implementing secure HTTP clients, WebView integration, or local storage Writing tests for Flutter widgets, Cubits, or Riverpod providers Wiring up GoRouter with authentication guards How It Works This skill provides copy-paste-ready Dart/Flutter code patterns organized by concern: 1. Null safety — avoid !, prefer ?./??/pattern matching 2. Immutable state — sealed classes, freezed, copyWith 3. Async composition — concurrent Future.wait, safe BuildContext after await 4. Widget architecture — extract to classes (not methods), const propagation, scoped rebuilds 5. State management — BLoC/Cubit events, Riverpod notifiers and derived providers 6. Navigation — GoRouter with reactive auth guards via refreshListenable 7. Networking — Dio with interceptors, token refresh with one-time retry guard 8. Error handling — global capture, ErrorWidget.builder, crashlytics wiring 9. Testing — unit (BLoC test), widget (ProviderScope overrides), fakes over mocks Examples --- Practical, production-ready patterns for Dart and Flutter applications. Library-agnostic where possible, with explicit coverage of the most common ecosystem packages. --- 1. Null Safety Fundamentals Prefer Patterns Over Bang Operator Avoid late Overuse --- 2. Immutable State Sealed Classes for State Hierarchies Freezed for Boilerplate-Free Immutability --- 3. Async Composition Structured Concurrency with Future.wait Stream Patterns BuildContext After Await --- 4. Widget Architecture Extract to Classes, Not Methods const Propagation Scoped Rebuilds --- 5. State Management: BLoC/Cubit --- 6. State Management: Riverpod --- 7. Navigation with GoRouter --- 8. HTTP with Dio --- 9. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/dart-flutter-patterns--bfc235