Dart Flutter Patterns

by affaan-mef648e01899bNo license275K starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 3 days ago

本番環境対応のDartおよびFlutterパターンは、null安全性、不変状態、非同期構成、ウィジェットアーキテクチャ、人気のある状態管理フレームワーク(BLoC、Riverpod、Provider)、GoRouterナビゲーション、Dioネットワーキング、Freezedコード生成、クリーンアーキテクチャをカバー。

Instructions onlySoftware Development
AI-generated overview

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

What it does
Supplies copy-paste-ready Dart and Flutter patterns organized by concern, covering null safety, immutable state, async composition, widget architecture, state management (BLoC, Riverpod, Provider), GoRouter navigation, Dio networking, error handling and testing. It includes illustrative code snippets such as sealed async state classes and a GoRouter with reactive auth redirect. It is an instructions-only reference with no scripts.
When to use it
Use it when starting a new Flutter feature and needing idiomatic patterns for state management, navigation or data access. It also fits reviewing or writing Dart code, setting up a Flutter project, implementing HTTP clients or local storage, writing widget or Cubit tests, and wiring GoRouter auth guards.
Requirements
No tools, packages or credentials are required beyond the agent; it ships no scripts and only provides guidance and code patterns.

Dart/Flutterパターン

使用時期

次の場合にこのスキルを使用:

  • 新しいFlutter機能を開始し、状態管理、ナビゲーション、またはデータアクセスのイディオマティックパターンが必要
  • Dartコードのレビューまたは作成とnull安全性、シール型、非同期構成のガイダンスが必要
  • 新しいFlutterプロジェクトをセットアップしBLoC、Riverpod、またはProviderのうち選択
  • 安全なHTTPクライアント、WebView統合、ローカルストレージを実装
  • FlutterウィジェットEt、Cubit、またはRiverpodプロバイダーのテストを作成
  • GoRouterを認証ガードでワイヤリング

動作方法

このスキルは、懸念事項で整理されたコピーペーストの準備ができたDart/Flutterコードパターンを提供:

  1. Null安全性 — !を避ける、?./??/パターンマッチングを好む
  2. 不変状態 — シール型、freezed、copyWith
  3. 非同期構成 — 並行Future.wait、await後の安全なBuildContext
  4. ウィジェットアーキテクチャ — クラスに抽出(メソッドではなく)、const伝播、スコープ付きリビルド
  5. 状態管理 — BLoC/Cubityベント、Riverpodノーティファイアおよび派生プロバイダー
  6. ナビゲーション — refreshListenable経由の反応型認証ガード付きGoRouter
  7. ネットワーキング — インターセプタ付きDio、ワンタイム再試行ガード付きトークンリフレッシュ
  8. エラーハンドリング — グローバルキャプチャ、ErrorWidget.builder、crashlyticsワイヤリング
  9. テスト — ユニット(BLoC test)、ウィジェット(ProviderScopeオーバーライド)、モック上のフェイク

例

dart
// シール状態 — 不可能な状態を防止sealed class AsyncState<T> {}final class Loading<T> extends AsyncState<T> {}final class Success<T> extends AsyncState<T> { final T data; const Success(this.data); }final class Failure<T> extends AsyncState<T> { final Object error; const Failure(this.error); }
// 反応型認証リダイレクト付きGoRouterfinal router = GoRouter(  refreshListenable: GoRouterRefreshStream(authCubit.stream),  redirect: (context, state) {    final authed = context.read<AuthCubit>().state is AuthAuthenticated;    if (!authed && !state.matchedLocation.startsWith('/login')) return '/login';    return null;  },  routes: [...],);

詳細については、ドキュメントを参照してください。

Source and attribution

Source:affaan-m/eccindocs/ja-JP/skills/dart-flutter-patternsat commitef648e0

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal