agentleFS
harshadmadayeharshadmadaye/OPM/skills/flutter-patterns/SKILL.md

flutter-patterns

Skill4 starsChanged 56 days agoMITView on GitHub

Provides production Flutter and Dart 3 patterns covering widget composition, state management choice (Riverpod, BLoC, plain ChangeNotifier), immutability with freezed and records, sealed-class state, async and streams, Firebase usage (Auth, Firestore, Functions), navigation, and widget/integration testing. Use when writing, reviewing, or architecting Flutter apps or Dart packages.

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always-true conventions (formatting, null safety, sealed types, errors, architecture, mobile security, test tooling) live in OPM's rules …

    line 12
  2. Very specific:

    Read references/dart-idioms-and-state.md when handling nulls, modelling state or data classes (sealed, freezed, records), or writing …

    line 37
  3. Very specific:

    Read references/widgets-and-navigation.md when composing widgets, scoping rebuilds, or setting up go_router.

    line 38
  4. Very specific:

    Read references/async-firebase-and-errors.md when writing async or stream code, using Firebase, or wiring error handling.

    line 39
  5. Very specific:

    Read references/testing.md when writing unit, widget, golden, or integration tests.

    line 40

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flutter Patterns

Small const widgets, immutable state modelled with sealed types, side effects in a thin layer above the UI, and tests at the widget boundary. Dart 3 features (records, patterns, sealed classes) are assumed.

Always-true conventions (formatting, null safety, sealed types, errors, architecture, mobile security, test tooling) live in OPM's rules dart/coding-style.md and dart/testing.md (.claude/rules/opm/dart/ once installed, rules/dart/ in the plugin). This skill keeps the patterns and worked examples.

When to use

  • Starting a Flutter feature and choosing how to structure widgets and state.
  • Reviewing Dart for null safety, immutability, async correctness, or rebuild scope.
  • Integrating Firebase services in a Flutter app.
  • Writing widget, unit, or integration tests.

State management

One approach per app: rule dart/coding-style.md (Architecture).

SituationChoice
Local, ephemeral UI state (a toggle, a text field, an animation)StatefulWidget + setState
App or feature state, most new appsRiverpod (code-generated providers)
Teams that want explicit event -> state transitions and event logsBLoC / Cubit
Tiny app or package with no dependency budgetChangeNotifier + ListenableBuilder

References

  • Read references/dart-idioms-and-state.md when handling nulls, modelling state or data classes (sealed, freezed, records), or writing Riverpod or Cubit code.
  • Read references/widgets-and-navigation.md when composing widgets, scoping rebuilds, or setting up go_router.
  • Read references/async-firebase-and-errors.md when writing async or stream code, using Firebase, or wiring error handling.
  • Read references/testing.md when writing unit, widget, golden, or integration tests.

Anti-patterns

  • user!.name where user?.name ?? default was possible.
  • Widget-returning private methods instead of widget classes.
  • setState for anything read outside the widget.
  • context used after an await without a mounted check.
  • Firestore queries or FirebaseAuth.instance calls inside build.
  • A Column inside SingleChildScrollView for a long list.
  • Catching Exception in the UI and showing e.toString().
  • Tests that pump the whole app to check one widget.

Review checklist

  • dart analyze clean; flutter test green.
  • State is sealed/immutable; updates create new objects.
  • Rebuild scope is minimal; const used where possible.
  • Every await in a widget is followed by a mounted guard before using context.
  • Firebase is behind repositories with withConverter; rules cover every access.
  • Subscriptions and controllers are disposed.
  • New behaviour has a widget or unit test that fails without it.

Related skills

  • opm:tdd-workflow - flutter test RED/GREEN cycle.
  • opm:verification-before-completion (full gate) - dart analyze and flutter test as the release gate.
<!-- Adapted from affaan-m/ecc (MIT) -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.