/flutter:flutter-conventions-indexfrom Flutter Skills
Entry point for Flutter/Dart app conventions: feature-first MVVM, Riverpod 3.x state/DI, immutable state, dumb widgets, typed errors, and a routing table to specialized skills. Use when starting work, reviewing features, or onboarding.
Ships in Flutter Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The front door for this Flutter/Dart app. It states the cross-cutting house rules every task obeys, then routes each concern to a focused skill. For any non-trivial task: apply the rules here, then open the specialized skill for depth. This is the only skill that names every other skill in the library.
Assumes a single-package Flutter app by default. Monorepo / pub-workspace guidance is fenced inside the skills that own it (project-structure-and-packages, codegen-and-toolchain) — never required for a small app.
flutter-architecture, project-structure-and-packages)build() is untestable and rebuilds unpredictably. (widget-composition)Notifier/AsyncNotifier owns private mutable state and exposes it as an immutable value with value equality; a transition assigns a new state, never mutates in place. WHY: immutable value + single owner makes every change diffable and testable. (state-management-riverpod)Notifier/AsyncNotifier/Future/Stream providers only; providers are the DI container. No get_it, no package:provider, no legacy StateProvider/StateNotifierProvider/ChangeNotifierProvider. WHY: one composition model, no second DI framework to reconcile. (state-management-riverpod, app-startup-and-bootstrap)state-management-riverpod, persistence-drift)flutter-architecture, service-boundary-and-native)freezed/sealed value types with copyWith and value equality. Pure functions are total — they return uncertainty, never throw. Recoverable I/O returns a sealed Result<T, F extends Failure>, switched exhaustively; never a swallowed catch (_) {}. WHY: the compiler enforces every case; failures carry a stable code, not a localized string. (error-handling-typed-results, dart3-idioms-and-coding-standards)Clock, never DateTime.now(). WHY: a global side effect is a non-deterministic, untestable dependency. (service-boundary-and-native, value-objects-money-and-units)await everything or handle the Future explicitly; no fire-and-forget arrow callbacks. Guard BuildContext/mounted after every await; dispose controllers, subscriptions, timers, and sinks. WHY: a dropped Future swallows errors no lint catches. (async-safety)dart3-idioms-and-coding-standards (method ≤30, build() ≤80, file ≤300, positional params ≤3, logic nesting ≤3 — widget build trees may nest to ≤5 as the stated exception). Extract const StatelessWidget classes, never _buildX() methods; const everywhere legal. WHY: small const subtrees rebuild less and read faster. (dart3-idioms-and-coding-standards, widget-composition, flutter-performance)…Screen/…Notifier/…Repository/…Service/…Failure; Effective-Dart casing verbatim; full words with units in the name; file named after its primary declaration. WHY: a grep or a filename should reveal the layer. (naming-conventions)start/end) geometry only, never hardcoded left/right; every user string comes from an ARB via gen_l10n; label and role every semantic node; never clamp the text scaler or rely on color alone. WHY: correctness properties are cheap to build in and expensive to retrofit. (i18n-rtl-l10n, accessibility-as-code)package:test + property invariants. Everything else: flutter_test + mocktail, ProviderContainer.test() + overrideWith — fake the repository/services, not the Notifier. One acceptance test anchors the whole app. WHY: tests follow risk; the pure core carries the invariants. (testing-strategy, widget-golden-and-a11y-testing)dart format clean and dart analyze --fatal-infos green before every PR, on a version-pinned very_good_analysis include with strict-casts/strict-raw-types. WHY: a green analyzer is the cheapest correctness signal you have. (lint-and-style-config, dependency-hygiene)| When you are… | Open |
|---|---|
| Orienting, unsure which skill governs the task | flutter-conventions-index (this) |
| Deciding layers, features-vs-packages, the dependency DAG | flutter-architecture |
Scaffolding packages, barrels, lib/ vs lib/src/, workspace layout | project-structure-and-packages |
Writing main(), error handlers, DI overrides, warm-up, app-lifecycle flush-on-background/resume | app-startup-and-bootstrap |
Writing a Notifier/AsyncNotifier, family/autoDispose, the single write path | state-management-riverpod |
Building or refactoring UI, writing build(), layout/insets | widget-composition |
| Configuring the app router, redirects/auth guards, deep links, nav shells, transitions, PopScope, 404 | navigation-and-routing |
Building a Form, sync/async field validation, focus traversal, keyboard actions, input formatters | forms-and-input |
| Rendering loading/empty/error states, snackbars, banners, dialogs, Undo, retry | ui-states-and-feedback |
Responsive breakpoints, large-screen/tablet/foldable master-detail, NavigationRail-vs-BottomNavigationBar by width | adaptive-layout |
| Choosing a Dart 3 construct (sealed, records, class modifiers) | dart3-idioms-and-coding-standards |
| Naming a class/file/variable/boolean | naming-conventions |
Configuring analysis_options.yaml, lint severity | lint-and-style-config |
| Fixing jank, narrowing rebuilds, lazy lists, off-isolate work | flutter-performance |
Writing /// doc comments on the public surface | dartdoc-conventions |
Writing async code, guarding context/mounted, disposal | async-safety |
Modeling errors, Result/Failure, never-lose-data flows | error-handling-typed-results |
| Writing unit/widget tests, setting up fakes | testing-strategy |
| Writing golden, layout, RTL, or accessibility widget tests | widget-golden-and-a11y-testing |
Adding a Drift table, DAO, or .watch stream | persistence-drift |
| Writing a forward-only schema migration | run-migration |
| Exporting, backing up, sharing, importing, or restoring user data | data-export-and-restore |
Setting up build_runner, build.yaml, generated-code policy | codegen-and-toolchain |
| Running codegen before analyze | run-codegen |
| Writing the GitHub Actions CI pipeline and gates | ci-pipeline-and-gates |
| Adding ARB strings, ICU plurals, RTL geometry | i18n-rtl-l10n |
Authoring Semantics, targets, traversal, text scaling | accessibility-as-code |
| Modeling money, units, dates in a pure core | value-objects-money-and-units |
| Building on-device reminders/notifications | local-notifications-scheduler |
Writing a CustomPainter + gesture hit-testing | custom-canvas-and-gestures |
| Adding an animation, a haptic, a celebration, or a success/error moment | motion-and-haptics |
| Generating content from a seed or date every device must reproduce identically | seeded-determinism-and-golden-vectors |
| Adding ads, a rewarded earn loop, a paywall, or an entitlement gate | ads-and-iap-monetization |
| Wiring a native channel or platform side effect | service-boundary-and-native |
Editing pubspec/lockfile, auditing a new dependency | dependency-hygiene |
| Scaffolding a whole feature module end to end | scaffold-feature-module |
| Structuring tokens → theme → components (no aesthetic values) | design-system-structure |
| Re-baselining committed golden images | run-goldens-rebaseline |
| Running the once-per-app design/QA review before release | design-review-workflow |
| Cutting a release: versioning, signing, symbols, store declarations, rollout | release-and-store-shipping |
dart3-idioms-and-coding-standards, value-objects-money-and-unitspersistence-drift, error-handling-typed-resultsservice-boundary-and-nativeNotifier/AsyncNotifier, family/autoDispose, intent methods → state-management-riverpodConsumerWidget, small const widget classes, forms, responsive layout, RTL-safe geometry, and the loading/empty/error states before the happy path is called done → widget-composition, ui-states-and-feedback, forms-and-input, adaptive-layout, i18n-rtl-l10n, accessibility-as-codego_router → app-startup-and-bootstrap, navigation-and-routing, scaffold-feature-module/// on the public surface; core invariants + container/widget tests with fakes → dartdoc-conventions, testing-strategy, widget-golden-and-a11y-testingflutter-performance, codegen-and-toolchain, ci-pipeline-and-gatesdesign-review-workflow, release-and-store-shippingThroughout: naming-conventions and lint-and-style-config keep every line honest.
# analysis_options.yaml
include: package:very_good_analysis/analysis_options.yaml # pin the version in pubspec
analyzer:
language:
strict-casts: true
strict-raw-types: true
# The PR gate (mirror in CI — see ci-pipeline-and-gates)
dart run build_runner build --delete-conflicting-outputs # if the app uses codegen
dart format --set-exit-if-changed .
dart analyze --fatal-infos --fatal-warnings
flutter test
// Repository = the SINGLE WRITE PATH: persist first, then observers re-emit.
class OrderRepository {
OrderRepository(this._db, this._clock);
final AppDatabase _db;
final Clock _clock;
/// The only route an order reaches storage. Returns a typed Result, never throws.
Future<Result<void, PersistFailure>> place(OrderDraft draft) async {
try {
await _db.transaction(() async {
await _db.orderDao.insert(draft.toRow(_clock.now())); // durable FIRST
});
return const Ok(null); // watchers over the DAO re-emit on commit
} on DriftException catch (e, s) {
return Err(PersistFailure.write(cause: e, stack: s));
}
}
}
// ViewModel = one StreamNotifier per screen; state tracks EVERY DAO emission.
// Riverpod 3.x: extend the unified base class, opt into autoDispose on the provider.
class OrderListNotifier extends StreamNotifier<List<Order>> {
@override
Stream<List<Order>> build() =>
ref.watch(orderRepositoryProvider).recent(); // re-emits on every commit
Future<void> place(OrderDraft draft) async {
final result = await ref.read(orderRepositoryProvider).place(draft);
switch (result) {
case Ok(): break; // the watched stream re-emits the new state
case Err(:final failure): state = AsyncError(failure, StackTrace.current);
}
}
}
final orderListProvider =
StreamNotifierProvider.autoDispose<OrderListNotifier, List<Order>>(
OrderListNotifier.new,
);
// View = dumb ConsumerWidget: reads one notifier, renders, no logic.
class OrderListScreen extends ConsumerWidget {
const OrderListScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return ref.watch(orderListProvider).when(
loading: () => const _OrdersSkeleton(),
error: (e, _) => _RetryView(onRetry: () => ref.invalidate(orderListProvider)),
data: (orders) => _OrderListView(orders: orders),
);
}
}
build(), or _buildXxx() helper methods — untestable and rebuild-unfriendly.setState for app/shared state; a mutable model edited by the UI — breaks the single owner + immutable-state rule.get_it/package:provider/legacy StateProvider/StateNotifierProvider/ChangeNotifierProvider — a second DI/state framework to reconcile.DateTime.now() in domain code — a non-deterministic dependency; inject a Clock.catch (_) {}), an untyped exception leaking to the UI, or a fire-and-forget Future — silent failure no lint catches.!/late/dynamic to dodge honest types; blanket // ignore; fighting dart format — hides the real defect.Notifier/AsyncNotifier owns immutable state; no legacy provider or extra DI container (rules 2–4).Result + sealed Failure, exhaustively switched; no swallowed errors (rule 7).Clock (rule 8).context/mounted guarded after awaits; controllers and subscriptions disposed (rule 9).const applied; names carry role + units (rules 10–11)./// docs; core invariants + container/widget tests with fakes pass (rule 13).dart format + dart analyze --fatal-infos clean on a pinned lint include (rule 14).Every skill in this table is a sibling; open the one the routing table points to. Start with flutter-architecture for where code goes, state-management-riverpod for how state flows, and error-handling-typed-results for the Result/Failure spine.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
flutter-conventions, mvvm, riverpod, feature-first, app-architecture
npx claudepluginhub zakariaf/flutter-skills --plugin flutter40 skills in this plugin
/accessibility-as-codeEnforces accessibility as a correctness property authored into each widget — Semantics(button/label) or ExcludeSemantics on every node, a11y state read from MediaQuery not app state, never MediaQuery.withClampedTextScaling / textScaleFactor / FittedBox / TextOverflow.ellipsis to fit a label, non-color redundant channels (icon+label+shape+text) for every state, contrast against composited backgrounds (4.5:1 body / 3:1 large), 44px single-tap targets, OrdinalSortKey traversal, and honoring boldText / reduce-motion. Use when adding a GestureDetector/InkWell or any tap target, adding an Icon or Image, reaching for withClampedTextScaling/FittedBox/ellipsis/textScaleFactor to make text fit, encoding state via color, sizing type, ordering focus traversal, or reviewing any View for screen-reader/switch/low-vision support./adaptive-layoutEnforces adapting layout by available CONSTRAINTS/size, never device or platform checks — LayoutBuilder + MediaQuery.sizeOf/paddingOf/viewInsetsOf (not .of) for narrow rebuilds, Material 3 window size classes (compact <600, medium 600-840, expanded 840-1200, large >1200) as the breakpoint vocabulary, navigation affordance chosen by width (NavigationBar → NavigationRail → NavigationDrawer), list-detail single-pane-vs-two-pane, readable max-width via ConstrainedBox, Flexible/Expanded/FractionallySizedBox over fixed widths, SafeArea + display cutouts + keyboard insets, never lock orientation, foldable/hinge awareness via MediaQuery.displayFeatures, and golden-matrix verification across sizes. Use when building responsive or adaptive UI, tablet/desktop/foldable support, master-detail or two-pane screens, a NavigationRail-vs-BottomNav shell, breakpoints, LayoutBuilder, MediaQuery sizing, SafeArea/cutouts, or fixing overflow at large widths./ads-and-iap-monetizationEnforces opt-in, rewarded-first monetization over the service seam — a rewarded view grants exactly one benefit and only on a genuine reward outcome (a sealed Rewarded/Dismissed/NoFill), earn loops capped per day against an injected Clock, the earn control preloaded and hidden unless an ad is loaded so a fresh account never dead-ends on "no ads available" (a Guideline 2.1 risk), interstitials only at a natural break under a count-and-elapsed cap owned by the service so callers stay dumb, no banner on the primary work surface, one non-consumable unlock plus Restore re-checked each launch and committed through the single write path before the UI reacts, one derived isEntitled provider as the only gate, and the entitlement restored BEFORE the ad SDK initializes so a paying user never starts it, resolves consent, or sees a tracking prompt. Use when adding ads, wiring a rewarded earn loop, placing an interstitial, building a paywall, gating an entitlement, or setting up ad units./app-startup-and-bootstrapEnforces a fixed main() cold-launch order — crash-log sink + FlutterError.onError + PlatformDispatcher.onError installed BEFORE any code that can throw, settings/theme read before runApp so the first frame paints correct, real infra constructed in a composition-root bootstrap() and injected via ProviderScope overrideWithValue over throwing placeholder providers, non-blocking warm-up deferred to addPostFrameCallback, exactly two error handlers with NO runZonedGuarded, ProviderException unwrapped before logging, and a WidgetsBindingObserver that flushes durable state on background/resume. Use when editing lib/main.dart, main_<flavor>.dart, bootstrap.dart or app.dart, reordering anything in main(), adding a splash/onboarding/permission gate, restoring theme before first paint, wiring a DB or service into ProviderScope, handling app-lifecycle background/resume flushes, or chasing cold-start latency, ANRs, or first-frame jank./async-safetyEnforces no-silent-failure async discipline in Flutter/Dart — the arrow-callback Future-drop hole no lint catches (`onTap: () => vm.save(x)`), void-returning event handlers, a mounted/ref.mounted guard after EVERY await before touching BuildContext, capturing Navigator/ScaffoldMessenger before the gap, honest `unawaited()` that always ends in catchError, no empty/bare catches, `rethrow` over `throw e`, and disposing every StreamSubscription/StreamController/Timer/sink. Use when writing or reviewing async/await, wiring onTap/onPressed/onSubmitted or any VoidCallback, touching BuildContext after an await, writing initState/dispose/addPostFrameCallback, adding a Timer or Future.delayed, writing a try/catch, or seeing use_build_context_synchronously, cancel_subscriptions, close_sinks, unawaited_futures, or discarded_futures./ci-pipeline-and-gatesEnforces a lean GitHub Actions Flutter CI where every gate maps to one named release-blocking contract — pinned runner + subosito/flutter-action@v2 toolchain, dart format --set-exit-if-changed, flutter analyze --fatal-infos, build_runner and drift schema freshness (git diff --exit-code), flutter test --test-randomize-ordering-seed random, static import/banned-string greps that catch what runtime can't, coverage-as-report-never-a-gate with the upward-lie fixed, verify-never-bless goldens (no --update-goldens in CI), and an honest statement of what CI cannot prove (audio, real fonts, on-device behaviour). Use when editing .github/workflows/*.yml, adding or removing a job or step, wiring a codegen/schema/format/analyze/coverage gate, writing a grep-based policy test or gate script under test/policy or tool/, pinning action versions, or claiming CI proves something it can't.Other plugins' skills for the same job