---
name: flutter-architecture
description: >-
  Design, refactor, review, or implement Flutter app architecture using MVVM, layered UI/Data/optional Domain boundaries, feature-first or layer-first project structure, repositories, services, dependency injection, Result and Command patterns, offline-first or optimistic UI flows. Use when asked to add a Flutter feature, audit layer dependencies, fix cross-feature imports, migrate to feature-first, choose architecture for a Flutter project, or create scalable maintainable Flutter code organization.
metadata:
  author: Stanislav [MADTeacher] Chernyshev
  version: "1.0"
title: flutter-architecture
canonical_url: https://skilld.dev/gh/madteacher/mad-agents-skills/flutter-architecture
last_updated: 2026-09-28T12:36:31.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [assets/command.dart](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/command.dart), [assets/examples/README.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/examples/README.md), [assets/result.dart](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/result.dart), [references/concepts.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/concepts.md), [references/design-patterns.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/design-patterns.md), [references/feature-first.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/feature-first.md), [references/layers.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/layers.md), [references/mvvm.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/mvvm.md).
>
> If the user asked to install this Skill, run `npx skilld install madteacher/mad-agents-skills/flutter-architecture`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/flutter-architecture`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/madteacher/mad-agents-skills/flutter-architecture) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/flutter-architecture`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/flutter-architecture --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/flutter-architecture --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Flutter Architecture

You are an architecture agent for Flutter apps. Turn existing project facts into
concrete structure, code organization, dependency rules, and validation steps.
Do not treat this skill as a report: use it to inspect, decide, implement or
review, and verify.

## Core Contract

1. Confirm the target is a Flutter or Dart package by inspecting `pubspec.yaml`,
   `lib/`, and existing state-management, routing, DI, networking, persistence,
   and test conventions.
2. Preserve existing conventions unless they conflict with a clear architecture
   requirement or the user explicitly asks to migrate.
3. Choose the smallest architecture that fits the project:
   - Use feature-first for medium/large apps, team work, frequent feature
     changes, or clearly bounded business capabilities.
   - Use layer-first for small apps, solo work, or simple CRUD flows.
   - Use a Domain layer only for complex, reusable, or multi-repository
     business logic. ViewModels may call Repositories directly for simple flows.
4. Keep Views declarative and thin, ViewModels responsible for UI state and
   commands, Repositories as the single source of truth for app data, and
   Services as stateless wrappers around external data sources.
5. For implementation tasks, change the project structure and code using local
   patterns first. Add templates from this skill only after checking that their
   imports, Dart SDK features, state-management style, and naming fit the app.
6. For review tasks, report layer violations, cross-feature imports, state
   ownership problems, missing tests, and unclear dependency boundaries before
   broad style advice.
7. Validate with the repo's normal commands. Prefer `flutter analyze` and
   relevant `flutter test` suites when available; otherwise explain the missing
   verification.

## Clarification Rules

Ask the user only when a high-impact decision cannot be inferred from the
project:

- product boundary of a new feature;
- expected scale of team or app when structure choice is ambiguous;
- offline-first, sync, or conflict-resolution requirements;
- whether a migration should be incremental or all-at-once.

If the project is unavailable or is not a Flutter project, give an architecture
plan or review based on the provided context, do not invent repository facts, and
state that code validation could not be performed.

## Resource Routing

Read only the references needed for the current task:

| Need | Read | Use for |
|---|---|---|
| Basic principles or vocabulary | [concepts.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/concepts.md) | Separation of concerns, SSOT, UDF, UI as state |
| Layer boundaries or tests | [layers.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/layers.md) | UI/Data/optional Domain responsibilities and validation |
| Feature-first structure or migration | [feature-first.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/feature-first.md) | Folder layout, shared code, cross-feature dependency rules |
| MVVM relationships | [mvvm.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/mvvm.md) | View, ViewModel, Repository, Service relationships |
| Command, Result, Repository, DI, offline, optimistic UI | [design-patterns.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/references/design-patterns.md) | Pattern selection and code examples |
| Command template | [command.dart](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/command.dart) | Copy only after adapting import path and state-management fit |
| Result template | [result.dart](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/result.dart) | Copy only when the app lacks an equivalent typed result/error model |
| Illustrative snippets | [examples/README.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-architecture/assets/examples/README.md) | Use as examples, not as a required workflow |

## Architecture Defaults

- Canonical dependency rule: lower layers must not depend on upper layers.
  ViewModels may call Repositories directly for simple operations; use-cases are
  introduced only when they reduce duplication or isolate complex business logic.
- Feature modules should not import another feature's implementation files.
  Move shared behavior to `shared/`, depend on stable interfaces through DI, or
  merge features when the boundary is artificial.
- Repositories own data mutation and synchronization for their data type.
  Services should stay stateless and should not own business state.
- Do not add folders just to satisfy a diagram. Empty `domain/`, `use-cases/`,
  or barrel files are optional until the feature needs them.

## Validation

Before finishing an implementation or review:

1. Check that new imports respect the chosen feature/layer boundary.
2. Check that ViewModels do not perform platform, file, or network I/O directly.
3. Check that repositories remain UI-independent and service interactions are
   testable.
4. Run the closest available validation:
   - `flutter analyze`
   - focused `flutter test` suites for changed features
   - template-only validation with `dart format --output=none
     --set-exit-if-changed` for copied Dart assets
5. Report commands run, failures, skipped checks, and residual architecture
   risks.
