---
title: "Flutter"
description: One folder, one bounded context, in Flutter.
source: flutter.dh.md
---
<!-- Made by dh llm from the source; nobody edits this file. -->

# Flutter

**Possible, with the weakest built-in guard.** A context is three packages in one folder: contract, src and tests. The API layer is screens and controllers.

## The files

```filetree
pubspec.yaml  # workspace, found by pattern
tool/
  bin/
    gen.dart
    boundaries.dart  # the guard
kernel/
  app/
    pubspec.yaml  (generated)  # lists every context, not committed
    lib/
      main.dart
      contexts.g.dart  (generated)
contexts/
  orders/
    context.yaml
    contract/
      pubspec.yaml
    src/
      pubspec.yaml
      lib/
        register.dart
        api/
          v1/
        mcp/
        domain/
        data/
    tests/
      pubspec.yaml
      unit/
      integration/
    policies.yaml
    flags.yaml
    config/
    observability/
    docs/
```

## What the tools allow

| Question | Answer | Tag |
| --- | --- | --- |
| Tests inside the folder | yes: 22 pass | MEASURED |
| A planted failing test | fails | MEASURED |
| A misnamed test file | skipped silently; our checker catches it | MEASURED |
| Tests or docs in the web build | 0 found | MEASURED |
| Hot reload after an edit | 0.55 s | MEASURED |

## An import the compiler lets through

```terminal
$ flutter analyze
   info • The imported package 'orders_ctx' isn't a dependency of the importing package.
$ dart run --directory=tool bin/boundaries.dart
contexts/billing/src/lib/register.dart: import "package:orders_ctx/register.dart": context "billing" imports the ctx project of "orders"
```

## What changes

| Change | Count | Tag |
| --- | --- | --- |
| Template files moved | 0 of 559 (no features in it) | REASONED |
| alcohol.neon files that change folder | 180 | MEASURED |
| Package files per context | 3 | MEASURED |
| alcohol.neon merge conflicts in 90 real merges | 0 | MEASURED |

## What does not work cleanly

- Two generated files are not committed. If they are stale, every Flutter command fails until `task gen`. MEASURED
- An undeclared import compiles and its tests pass. MEASURED
- Tests on a device were not run. NOT TESTED
