How do you manage a Flutter monorepo with Melos?
TL;DR: Melos manages Flutter/Dart monorepos: multiple packages in one git repo with shared tooling. Commands like 'melos run test --all' or 'melos run build --diff origin/main' run scripts across changed packages. Melos version handles coordinated package versioning and CHANGELOG generation.
Full Answer
A Flutter monorepo contains the app + feature packages + shared packages in one repository. Melos, like Nx for JS, provides cross-package scripts, dependency graphing, and coordinated versioning.
Melos Commands
- ▸melos bootstrap: links local packages with path dependencies, runs pub get
- ▸melos exec: run any command in each package
- ▸melos run <script>: run named scripts from melos.yaml
- ▸melos version: bump versions, generate CHANGELOGs, create release commits
- ▸--diff origin/main: only run in packages changed since main branch
The --diff flag is the key performance feature: in CI, only test/build packages that changed in the PR. A 20-package monorepo tests only 2 changed packages instead of all 20.
Code Examples
// melos bootstrap: links packages locally // CI: 'melos test:changed' tests only modified packages // version: bumps all inter-dependent packages atomically
Common Mistakes
- ✗Not running melos bootstrap after adding a new package — inter-package path dependencies aren't linked
- ✗Running all tests in CI instead of --diff — CI gets slower as monorepo grows
Interview Tip
Melos is used by major Flutter open source projects (FlutterFire, BrickHub). Show you know the --diff flag for CI optimization — it's the key feature that makes monorepos scalable in CI.