flutter-best-practices
Skill669 starsChanged 3 months agoMITView on GitHub
Use when writing, reviewing, refactoring, or planning Flutter/Dart code — screens, features, project structure, state management, folders, widgets, cubits/blocs, repositories, services, or tests.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- kitloomlk-stack/mobile-apps-kitword for word, first seen Oct 15, 2026
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
- Mauriciog87/flutter-agent-skilltheir own version, first seen Feb 3, 2026
Other versions3 projects use a version of this.
Word for word · 1
- kitloomlk-stack/mobile-apps-kit★ 0100% same
Edited · 0
None found.
Wrote their own version · 2
- baekenough/oh-my-customcode★ 42same name
- Mauriciog87/flutter-agent-skill★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibilitySkill
- architecture-feature-firstSkill
- blocSkill
- code-reviewSkill
- dart-3-updatesSkill
- developing-genkit-dartSkill
- effective-dartSkill
- firebase-aiSkill
- firebase-analyticsSkill
- firebase-app-checkSkill
- firebase-authSkill
- firebase-cloud-firestoreSkill
- firebase-cloud-functionsSkill
- firebase-crashlyticsSkill
- firebase-databaseSkill
- firebase-data-connectSkill
- firebase-in-app-messagingSkill
- firebase-messagingSkill
- firebase-remote-configSkill
- firebase-storageSkill
- flutter-app-architectureSkill
- flutter-change-notifierSkill
- flutter-errorsSkill
- flutterfire-configureSkill
- flutter-pre-cachingSkill
- flutter-use-column-row-firstSkill
- generate-images-with-firebase-aiSkill
- inclusive-designSkill
- mockitoSkill
- mocktailSkill
- patrol-e2e-testingSkill
- providerSkill
- revenuecat-testingSkill
- riverpodSkill
- testingSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Read the reference file that matches the task.
- Distinctive: line 52
Add layers only when they pay for themselves: Start with view-model → API client.
- Very specific: line 60
Prefer intent-revealing widgets over
Container: Use Padding, SizedBox, ColoredBox, DecoratedBox, Center — they are const-able and … - Very specific: line 70
Tests tell a story: Use expressive matchers (isEmpty, throwsA, isA, completion) and minimize dependencies — plain Text/SizedBox over …
- Distinctive: line 89
Add unit tests for the cubit/view model logic before wiring UI details.
- Distinctive: line 93
Check, in order of importance:
- Distinctive: line 109
If more than ~2 teams or clearly separable domains are involved, read references/enterprise-scale.md and consider a Melos monorepo with one …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Flutter Best Practices
Standards for building maintainable Flutter apps, distilled from the official Flutter architecture guide and LeanCode's experience shipping 40+ Flutter projects (including a 30-developer banking app). Apply these when writing new code; when touching existing code, prefer consistency with the surrounding codebase and raise conflicts with these standards rather than silently rewriting.
How to use this skill
Read the reference file that matches the task. Read more than one when tasks overlap (e.g. a new feature touches both structure and coding style).
| Task | Read |
| Design layers, decide where logic lives, MVVM, repositories/services | references/architecture-layers.md |
| Create/organize a feature, folder structure, state management wiring | references/feature-structure.md |
| Write or review Dart/Flutter code, widgets, tests, lints | references/dart-coding-practices.md |
| Multi-team/multi-package apps, monorepo, navigation, localization, API contracts, E2E tests | references/enterprise-scale.md |
| App localization setup, reusable UI package string ownership, language picker visibility | references/localization-package-boundaries.md |
For a quick task (small widget fix, one-line review comment), the core rules below may be enough on their own.
Core rules (always apply)
Architecture
- Separate UI from data. Two broad layers: UI (views + view models /
cubits) and Data (repositories + services). Dependencies point one way:
View → ViewModel → Repository → Service. Lower layers never import upper layers. Repositories never depend on each other. - Views hold no business logic. Widgets may contain show/hide
conditionals, animation, layout, and simple routing logic — nothing that
transforms or decides about data. All data logic lives in the view model
(or cubit/bloc), which has no access to
BuildContext. - Organize by feature, not by layer. Everything a feature needs — state
management, widgets, models — lives under one feature directory. Don't
create top-level
blocs/,widgets/,models/buckets that scatter a feature across the tree. - State is immutable and explicit. Model UI state as a sealed/union type (initial / inProgress / failure / ready) so every case is handled exhaustively. One-off effects (snackbars, navigation) are events, not state.
- Add layers only when they pay for themselves. Start with view-model → API client. Introduce a repository when you need caching, offline, or merging sources. Introduce a use case only when logic merges multiple repositories, is genuinely complex, or is reused by several view models.
Coding
- Prefer intent-revealing widgets over
Container. UsePadding,SizedBox,ColoredBox,DecoratedBox,Center— they are const-able and self-describing.Containeris fine only when combining several properties at once. - Use modern Dart. Pattern matching (
if (x case final v?)), switch expressions with exhaustiveness, records and destructuring, collectionif/for/spreads instead of.add()loops, expression bodies for pass-through async functions (no redundantasync/await). - Prefix sliver-returning widgets with
Sliverso misuse in the wrong scroll context is caught at a glance. - Tests tell a story. Use expressive matchers (
isEmpty,throwsA,isA,completion) and minimize dependencies — plainText/SizedBoxover design-system widgets in test fixtures. Test cubits/view models in isolation from the widget tree. - Every
// ignore:gets a reason on the same or preceding line. Log errors with dedicatederror/stackTraceparameters, never string interpolation.
Workflow checklists
Adding a new feature/screen
- Read references/feature-structure.md and mirror the existing project's conventions for the feature directory.
- Define the state as a union type first; then the cubit/view model; then the widgets. Constructor-inject dependencies; scope them to the feature's widget subtree.
- Data comes in through a repository or typed API client — never fetched inside a widget.
- Add unit tests for the cubit/view model logic before wiring UI details.
Reviewing Flutter code
Check, in order of importance:
- Logic in the right layer (rule 1–2)? Any
BuildContextin business logic? - State modeled as immutable union types, all cases handled?
- Feature self-contained, or does it reach into another feature's internals?
- Widget choices (rule 6), modern Dart (rule 7), sliver naming (rule 8)?
- Tests present for logic, readable, minimal dependencies?
- Unexplained
// ignore:, string-interpolated error logs, deprecated patterns still spreading?
Starting a new project
- Read references/architecture-layers.md for the layer blueprint and references/feature-structure.md for the folder skeleton.
- If more than ~2 teams or clearly separable domains are involved, read references/enterprise-scale.md and consider a Melos monorepo with one package per domain from day one.
- Set up strict lints early (
leancode_lintor equivalent + custom rules) — retrofitting is far more expensive.
Package palette
Defaults that these standards assume (swap for project-local equivalents when the codebase already uses something else):
- State:
bloc(Cubit) +freezedfor union-type states;bloc_presentationfor one-off UI events - DI:
providerscoped to widget subtrees (accepting its lack of compile-time safety as the lesser evil) - Boilerplate reduction:
flutter_hooks - Monorepo:
melos - Localization:
flutter_localizations+intlwith.arbfiles - Lints:
leancode_lint - E2E/UI tests:
patrol
The official Flutter guide is state-management-agnostic (MVVM with ChangeNotifier works too); what matters is the layer separation, not the package. See the reference files for rationale and trade-offs.
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
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.

