Flutter¶
Scope: cross-platform apps built with Flutter and Dart.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
The Flutter team publishes an official architecture guide. Follow it as-is.
- 10 Flutter app architecture: the baseline. It covers concepts, the guide and a case study.
- 9 Architecture recommendations: a prioritised checklist. Use it for reviews.
- 8 Compass sample app: the reference app for the guide.
- 8 Effective Dart: style, documentation, usage and design rules for Dart.
- 7 Design patterns: offline-first, command, result and other patterns.
Key rules¶
Architecture¶
- 9
FLUTTER-1Separate the UI layer (views and view models) from the data layer (repositories and services), and add a domain layer of use cases only when needed. (Flutter, Guide to app architecture) - 8
FLUTTER-2Make repositories the source of truth for app data, with services that wrap external APIs. (Flutter, Guide to app architecture) - 8
FLUTTER-3Use unidirectional data flow and immutable data models. (Flutter, Architecture recommendations) - 7
FLUTTER-4Cover logic with unit tests, widgets with widget tests, and critical flows with integration tests. (Flutter, Testing overview) - 6
FLUTTER-5Choose a state management approach that fits the app and the team, and use it consistently for app state.setStateis fine for widget-local state. (Flutter, State management options, Ephemeral vs. app state) - 5
FLUTTER-6Model user actions as commands, and model operation outcomes asResultvalues instead of throwing across layers. (Flutter, Command pattern, Result pattern)
Accessibility¶
- 7
FLUTTER-7Describe custom widgets to screen readers with theSemanticswidget, setting a label and properties such asbuttonorheader, and make every tap target at least 48 by 48 dp on Android and 44 by 44 pt on iOS. Flutter's standard widgets build the accessibility tree automatically,MergeSemanticsmakes a subtree a single node, andExcludeSemanticsremoves decoration from the tree; test with TalkBack and VoiceOver. This appliesA11Y-9. (Flutter, Accessibility technologies, Flutter API, Semantics class, Flutter, UI design and styling: tap target size) - 6
FLUTTER-8Let text follow the font size set in the operating system, which Flutter's text widgets do by default, and make every layout leave room for text at the largest setting, testing on a small screen. Read other settings that the platform reports, such as bold text, high contrast and inverted colours, fromAccessibilityFeatures. This appliesA11Y-12. (Flutter, UI design and styling: large fonts, Flutter, Other accessibility features)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 7 Dart analyzer with flutter_lints: the lint set the Flutter team recommends.
must_be_immutableandprefer_final_fieldscatch mutable fields in data models. Partly checksFLUTTER-3. - 6 Flutter accessibility guideline matchers,
meetsGuideline: in widget tests,androidTapTargetGuidelineandiOSTapTargetGuidelinecheck minimum tap target sizes,labeledTapTargetGuidelinechecks that tappable elements have a label, andtextContrastGuidelinechecks text contrast against WCAG. Accessibility testing shows a complete test. Partly checksFLUTTER-7. - 4 DCM, avoid-banned-imports (commercial): bans imports per folder, for example UI code importing services directly. Checks
FLUTTER-1. - 4 bloc_lint, avoid_flutter_imports (for apps that use Bloc): keeps Flutter out of business logic components, and avoid_public_fields keeps state exposed only through the state object. Partly checks
FLUTTER-1andFLUTTER-3.