dart-flutter-patterns

Provides production-ready Dart and Flutter code patterns for state management, navigation, networking, and testing.

Updated May 7, 2026
One-click install
npx skills add https://github.com/mirzadham/trainingroombookingsystem2 --skill dart-flutter-patterns-mirzadham
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-flutter-patterns
Source: https://github.com/mirzadham/trainingroombookingsystem2/tree/main/.pi/skills/dart-flutter-patterns
Command: npx skills add https://github.com/mirzadham/trainingroombookingsystem2 --skill dart-flutter-patterns-mirzadham

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter developers often struggle to choose idiomatic patterns for null safety, state management, navigation, and networking, leading to inconsistent or fragile code. This Skill provides copy-paste-ready Dart and Flutter patterns covering the most common architectural decisions. ## Core Features & Use Cases - State Management Patterns: Ready-to-use implementations for BLoC/Cubit, Riverpod notifiers, and derived providers with sealed state classes. - Navigation & Networking: GoRouter setup with reactive auth guards and Dio HTTP clients with token refresh interceptors and retry guards. - Widget Architecture & Testing: Guidance on const propagation, scoped rebuilds, BuildContext safety after await, plus unit, BLoC, and widget test examples. - Use Case: When starting a new Flutter feature, use this Skill to scaffold an authentication flow with an AuthCubit, GoRouter redirect logic, and a Dio client with automatic token refresh. ## Quick Start Ask the AI to show the recommended Flutter pattern for implementing a Riverpod cart notifier with derived providers and widget tests.

Frequently Asked Questions about dart-flutter-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement state management in Flutter with Riverpod?▼

Use @riverpod annotated providers for async data and Notifier classes for mutable state like a cart. Derived providers can watch other providers to compute values such as totals, and auto-dispose keeps memory usage bounded.

BLoC vs Riverpod vs Provider for Flutter state management?▼

BLoC/Cubit suits event-driven flows with explicit state transitions and blocTest support. Riverpod offers compile-safe dependency injection and derived providers, while Provider fits simpler cases. The skill covers all three with concrete examples.

How do I set up GoRouter with authentication redirects in Flutter?▼

Pass a refreshListenable wrapping your auth state stream so redirects re-evaluate on login changes. In the redirect callback, check authentication state and return '/login' for unauthenticated users or null to allow navigation.

How do I handle token refresh with Dio interceptors?▼

Add an InterceptorsWrapper whose onError checks for 401 responses, attempts a token refresh, and retries the request once. Mark retried requests with an extra flag like '_isRetry' to prevent infinite retry loops.

Why does my Flutter app crash when using context after await?▼

Using BuildContext after an await is unsafe because the widget may have been unmounted during the async gap. Always check the mounted property on State before calling context-dependent methods like navigation or SnackBars.

When should I avoid using the late keyword in Dart?▼

Avoid late for values that might be accessed before initialization, since it defers null errors to runtime. It is acceptable only when initialization is guaranteed first, such as an AnimationController created in initState.