flutter-architect
Principal Flutter Architect — full-stack design + develop. Dart 3.13, Flutter 3.47, Material 3, Riverpod/BLoC, go_router, 60 FPS, cross-platform (iOS/Android/web/desktop), CI/CD, testing. Do not use f
Files1
View on GitHubSKILL.mdskills/flutter-architect/SKILL.md
GitHub[SKILL] flutter-architect
[OBJ] Architect, design, build, profile, and ship production-grade Flutter apps across iOS, Android, web, and desktop from a single Dart codebase — owning both the visual layer (design system, theming, motion, accessibility) and the engineering layer (state, architecture, networking, persistence, testing, CI/CD).
[PERSONAS] MOBILE (primary), UX (primary), ARCH (secondary), DEV (secondary).
[SUB-SKILLS] flutter-design (UX/visual layer), flutter-developer (engineering layer).
[RULES]
- [CMD] Context7 IDs: Flutter
/flutter/website; Flutter API/websites/api_flutter_dev; Flutter Packages/flutter/packages; Dart/dart-lang/site-www; Riverpod/riverpod/riverpod; go_router/flutter/packages(go_router subpath); BLoC/felangel/bloc; Freezed/rrousselGit/freezed; Drift/simolus3/drift. - [REQ]
[VER-01]Pin to lockfile exact versions. Readpubspec.lock-> grepflutter:sdk:dart:-> loadtech-stack/flutter-<ver>.md. NEVER assume Flutter version; default reference is Flutter 3.47 / Dart 3.13 (Aug 2026). Material 3 is default ON since Flutter 3.16 — never setuseMaterial3: falsewithout justification. - [REQ] Project anatomy (feature-first):
lib/{core,features,config,l10n,routing}; one feature = one folder withdata/(models, datasources, repos),domain/(entities, repo interfaces, usecases),presentation/(widgets, pages, controllers). Keepmain.dart< 30 lines; app entry only. - [REQ] Architecture: clean-ish layering (presentation -> domain -> data). Dependency rule: presentation depends on domain, data depends on domain, domain depends on nothing. No
BuildContextin domain/data. No business logic inbuild(). - [REQ] State management decision tree: local ephemeral UI state ->
setState/ValueNotifier; scoped shared state -> Riverpod (preferNotifier/AsyncNotifier+ref.watch/ref.read, avoid legacyStateProviderfor complex state); event-driven / strict separation / large teams -> BLoC (Cubit for simple). NEVER use InheritedWidget manually for app state. NEVER mixsetStatewith a global store. - [REQ] Immutability: models via
freezed+json_serializable;constconstructors everywhere possible;@immutableon widgets holding mutable fields flagged. Use Dart 3.13 primary constructors for concise immutable data classes when language version >= 3.1. - [REQ] Routing:
go_router+go_router_builderfor all non-trivial apps. Declarative routes withTypedGoRoute/TypedStatefulShellRoute(compile-time safe viago_router_builder);ShellRoute/StatefulShellRoute.indexedStackfor nested nav with state preservation;redirectfor auth guards;extrafor typed args (define route-arg classes, never rawMap). UsePopScope(NOT deprecatedWillPopScope) for Android predictive back (Android 14+). Router Refresh Pattern: use_RouterRefreshNotifier(ChangeNotifier) +ref.listento trigger redirects on auth state change WITHOUT rebuilding the router (preserves bottom nav state). - [REQ] Theming & design system: single
ThemeDataviaColorScheme.fromSeed()+TextTheme(GoogleFonts or bundled fonts); expose viaTheme.of(context)ONLY — no hardcodedColor(0x...)in widgets. Support light + dark + system. Define spacing/radius/elevation tokens as constants orThemeExtension. Seeflutter-designfor full design-system rules. - [REQ] Networking:
dio(interceptors: auth, logging, retry, error-mapping) orhttpfor simple; optionalretrofitfor type-safe API definitions (@RestApi()annotations +retrofit_generator). Deserialize viafreezed+json_serializable; repository pattern wraps datasources; never call HTTP from widgets. Backend isolation: backend SDK (Firebase, Supabase) imports forbidden outsidedata/layers and entrypoints — domain/presentation remain backend-agnostic. Handle loading/error/empty states explicitly in every async view. Freezed Failure union:@freezed class Failure { network/cache/auth/server/permission/unknown }with exhaustive pattern matching. - [REQ] Persistence:
drift(typed SQLite),hive/isarfor KV,shared_preferencesfor primitives only. Local-first with conflict resolution for offline apps; encrypt sensitive stores (flutter_secure_storage). - [REQ] Performance budget: 60 FPS (16.6 ms/frame); profile with Flutter DevTools (Performance + CPU/Memory tabs). Use
constwidgets,RepaintBoundaryaround animations,ListView.builder(neverListView(children:)for >20 items),itemExtentwhen known,AutomaticKeepAliveClientMixinsparingly. Avoid rebuilds: scopeConsumer/Selectorto the smallest subtree; preferref.watchin leaf widgets. - [REQ] Accessibility:
Semanticson custom gesture widgets; respectMediaQuery.textScaler(never fixed font sizes); large-tap-targets >= 48x48 dp; test with TalkBack + VoiceOver;ExcludeSemanticsonly when overriding. WCAG AA contrast viaColorScheme. - [REQ] Testing two-tier
[TEST-07]: FAST ->flutter test test/path/to/touched_test.dart(~5s); FULL ->flutter test --coverage(target >= 80% logic, >= 70% total) +flutter test integration_test/. Widget tests viatestWidgets+WidgetTester; mock withmocktail(Dart-friendly, no annotation boilerplate). One behavior per test (AAA). No hardcoded IDs/dates — use factories. - [REQ] CI/CD: GitHub Actions / Codemagic / Fastlane. Lanes:
analyze(flutter analyze --fatal-infos),format(dart format --set-exit-if-changed),test,build(per platform),deploy. Build AAB (Android) + IPA/XCArchive (iOS); sign via Play App Signing + App Store Connect API key. Pin action SHAs[GIT-05]; OIDC keyless where supported. - [REQ] L10n:
flutter_localizations+intl+ ARB files;gen-l10nfor typedAppLocalizations; OR Slang (^4.12.0) for compile-time safe translations with zero runtime lookup. Never hardcode user-facing strings; RTL-aware layouts (testDirectionality(textDirection: TextDirection.rtl)); mirror directional icons. - [REQ] Security
[SEC-01..10]: zero-trust input validation (Form + validators); no secrets in code (use.env+--dart-define/flutter_dotenv); HTTPS only + certificate pinning for sensitive APIs;flutter_secure_storagefor tokens; obfuscate release builds (--obfuscate --split-debug-info); Play Integrity / DeviceCheck for anti-tamper. - [REQ] Code quality
[CODE-01..05]: widget files < 300 lines,build()< 30 lines; extract widgets to classes (not methods) for perf + reuse; enums/constants over magic strings; strict typing — avoiddynamic, prefer sealed classes / pattern matching (Dart 3). NoTODO/FIXMEwithout ticket tag. - [REQ] Cross-platform: feature-detect with
Platform.isIOS/Platform.isAndroid/kIsWeb;MediaQuery.padding/SafeAreafor notches; adaptive widgets (Platform.isIOS ? CupertinoActionSheet : BottomSheet); responsive viaLayoutBuilder+ breakpoints (compact < 600, medium 600-840, expanded > 840). - [REQ] Animations: implicit (
AnimatedContainer/AnimatedOpacity) for simple;AnimationController+CurvedAnimationfor sequenced;Herofor shared-element transitions;Rive/Lottiefor designer-authored;CustomPainter+RepaintBoundaryfor canvas. Dispose controllers. - [REQ] Query Context7 for ANY Flutter/Dart/package API before implementation. Test on physical devices (iOS + Android) before declaring done. Run
flutter analyze+dart format+ targeted tests during iteration; FULL suite + coverage before done. - [REQ] UseCase pattern:
abstract class UseCase<R, P> { Future<Result<R>> call(P params); }— encapsulates single business operations, testable, reusable. Each feature's domain layer exposes usecases that controllers call. - [REQ] Multi-flavor:
main_dev.dart,main_staging.dart,main_production.dartentry points with separate Firebase/env configs.--flavor+--dart-define-from-filefor environment injection. - [REQ] Observability:
sentry_flutterfor crash reporting +posthog_flutterfor product analytics + feature flags + session replay. Wire observers into router for automatic screen tracking. Reset analytics identity on logout. - [REQ] E2E testing:
integration_test(floor) + Patrol (ceiling — handles native permission dialogs, system sheets). Maestro (YAML, cross-platform) for black-box E2E if team prefers non-Dart authoring. - [REQ] IAP/Monetization:
in_app_purchaseplugin for Flutter IAP; RevenueCat for subscription lifecycle management (cross-platform, server-side receipt validation).
[PROHIBIT]
useMaterial3: falsewithout explicit justification.WillPopScope(deprecated — usePopScope).setStatefor app-wide/shared state.InheritedWidgetmanual for app state (use Riverpod/BLoC).ListView(children:)for > 20 items.- Hardcoded
Color(0x...)/TextStyle(fontSize:)in widgets (useTheme.of). dynamicin public APIs.- Business logic inside
build(). - Secrets committed to repo / hardcoded API keys.
git add ./git add -A[GIT-06].