Setting Up Monorepo Management for Flutter with Melos

Summary
Summary
Summary
Summary

Learn how to set up Melos for Flutter monorepo management: install and initialize, structure workspaces, define shared scripts, and integrate CI/CD. Achieve streamlined dependency handling, task orchestration, and consistent builds across apps and packages in your mobile development workflow.

Learn how to set up Melos for Flutter monorepo management: install and initialize, structure workspaces, define shared scripts, and integrate CI/CD. Achieve streamlined dependency handling, task orchestration, and consistent builds across apps and packages in your mobile development workflow.

Learn how to set up Melos for Flutter monorepo management: install and initialize, structure workspaces, define shared scripts, and integrate CI/CD. Achieve streamlined dependency handling, task orchestration, and consistent builds across apps and packages in your mobile development workflow.

Learn how to set up Melos for Flutter monorepo management: install and initialize, structure workspaces, define shared scripts, and integrate CI/CD. Achieve streamlined dependency handling, task orchestration, and consistent builds across apps and packages in your mobile development workflow.

Key insights:
Key insights:
Key insights:
Key insights:
  • Installing Melos and Initializing Your Monorepo: Melos bootstrap links all pubspecs, creating a unified lockfile and local path resolution.

  • Structuring Projects and Workspaces: Organize shared Dart packages and Flutter apps under packages/ and apps/ for clear modular boundaries.

  • Managing Dependencies and Scripts: Use Melos scripts to run analysis, tests, and formatting across all workspaces, and add custom Dart tools.

  • Integrating CI/CD Pipelines: Leverage Melos in CI workflows to bootstrap, cache dependencies, and execute quality checks consistently.

Introduction

Managing multiple Flutter packages and apps in a single repository can streamline your development workflow, enforce consistent tooling, and simplify dependency sharing. Monorepo setups avoid version drift between libraries, accelerate local testing, and improve CI performance. Melos is a CLI tool specifically designed to orchestrate, manage scripts, and handle dependencies in Dart and Flutter monorepos. In this tutorial, we’ll walk through setting up Melos in a Flutter monorepo, structuring workspaces, running custom scripts, and integrating with CI/CD pipelines. By the end, you'll have a robust, maintainable monorepo foundation for your Flutter mobile development projects.

Installing Melos and Initializing Your Monorepo

First, ensure you have Dart and Flutter SDKs installed. Then globally activate Melos:

dart pub global activate melos

Or with Flutter:

flutter pub global activate melos

Next, create a new repository structure:

mkdir flutter_monorepo && cd flutter_monorepo
git init
mkdir packages apps

Inside the root, add a melos.yaml to configure packages and workspace policies:

dir:
  packages:
    - 'packages/*'
    - 'apps/*'
name: flutter_monorepo
enablePublish: false

Run melos bootstrap to install dependencies across all packages and apps. Melos will detect each pubspec, link local paths, and ensure a single lock file at the root.

Structuring Projects and Workspaces

Melos treats each pubspec folder as a workspace. Organize shared utilities and UI components under packages/, and Flutter applications under apps/. For example:

flutter_monorepo/
├─ packages/
├─ ui_components/
└─ data_models/
└─ apps/
   ├─ app_a/
   └─ app_b

In packages/ui_components/pubspec.yaml, reference data_models as a path dependency:

dependencies:
  flutter:
    sdk: flutter
  data_models:
    path

After updating pubspecs, rerun melos bootstrap. All workspaces now share a single package resolution, making cross-package references seamless.

Managing Dependencies and Scripts

Melos simplifies running commands across all workspaces. Define scripts in melos.yaml under a scripts: section:

scripts:
  analyze:
    run: dart analyze .
  test:
    run: flutter test --coverage
  format:
    run

Invoke melos run analyze to run Dart analysis in every package and app. To run only in specific folders, use melos exec:

melos exec --scope=ui_components -- flutter test

You can also create custom scripts in Dart for code generation or other tasks. For example, a simple build script in tool/build.dart:

// tool/build.dart
import 'dart:io';
void main(List<String> args) {
  Process.runSync('flutter', ['pub', 'run', 'build_runner', 'build'],
      runInShell: true, stdout: stdout, stderr: stderr);
}

Then add it to Melos:

  build:
    run

Integrating CI/CD Pipelines

In your CI workflow (GitHub Actions, GitLab CI, etc.), use Melos to bootstrap and run scripts in a cached environment. Example GitHub Actions snippet:

name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Flutter
        uses: subosito/flutter-action@v2
      - name: Install Melos
        run: flutter pub global activate melos
      - name: Bootstrap Monorepo
        run: melos bootstrap --no-utf-8
      - name: Run Analyzer
        run: melos run analyze
      - name: Run Tests
        run

Cache .pub-cache and ~/.pub-cache directories to speed up builds. This pipeline ensures consistent analysis, formatting, testing, and build steps across every package and app.

Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.

Conclusion

Melos brings order and automation to Flutter monorepos, making it easy to share code, enforce standards, and orchestrate workflows. By installing Melos, defining clear workspaces, and setting up scripts, you gain a centralized management layer for dependencies, tests, and builds. Integrating Melos into your CI/CD pipelines maintains consistency across projects and accelerates development velocity. Adopt Melos today to streamline your Flutter mobile development and unlock the full potential of monorepo architecture.

Introduction

Managing multiple Flutter packages and apps in a single repository can streamline your development workflow, enforce consistent tooling, and simplify dependency sharing. Monorepo setups avoid version drift between libraries, accelerate local testing, and improve CI performance. Melos is a CLI tool specifically designed to orchestrate, manage scripts, and handle dependencies in Dart and Flutter monorepos. In this tutorial, we’ll walk through setting up Melos in a Flutter monorepo, structuring workspaces, running custom scripts, and integrating with CI/CD pipelines. By the end, you'll have a robust, maintainable monorepo foundation for your Flutter mobile development projects.

Installing Melos and Initializing Your Monorepo

First, ensure you have Dart and Flutter SDKs installed. Then globally activate Melos:

dart pub global activate melos

Or with Flutter:

flutter pub global activate melos

Next, create a new repository structure:

mkdir flutter_monorepo && cd flutter_monorepo
git init
mkdir packages apps

Inside the root, add a melos.yaml to configure packages and workspace policies:

dir:
  packages:
    - 'packages/*'
    - 'apps/*'
name: flutter_monorepo
enablePublish: false

Run melos bootstrap to install dependencies across all packages and apps. Melos will detect each pubspec, link local paths, and ensure a single lock file at the root.

Structuring Projects and Workspaces

Melos treats each pubspec folder as a workspace. Organize shared utilities and UI components under packages/, and Flutter applications under apps/. For example:

flutter_monorepo/
├─ packages/
├─ ui_components/
└─ data_models/
└─ apps/
   ├─ app_a/
   └─ app_b

In packages/ui_components/pubspec.yaml, reference data_models as a path dependency:

dependencies:
  flutter:
    sdk: flutter
  data_models:
    path

After updating pubspecs, rerun melos bootstrap. All workspaces now share a single package resolution, making cross-package references seamless.

Managing Dependencies and Scripts

Melos simplifies running commands across all workspaces. Define scripts in melos.yaml under a scripts: section:

scripts:
  analyze:
    run: dart analyze .
  test:
    run: flutter test --coverage
  format:
    run

Invoke melos run analyze to run Dart analysis in every package and app. To run only in specific folders, use melos exec:

melos exec --scope=ui_components -- flutter test

You can also create custom scripts in Dart for code generation or other tasks. For example, a simple build script in tool/build.dart:

// tool/build.dart
import 'dart:io';
void main(List<String> args) {
  Process.runSync('flutter', ['pub', 'run', 'build_runner', 'build'],
      runInShell: true, stdout: stdout, stderr: stderr);
}

Then add it to Melos:

  build:
    run

Integrating CI/CD Pipelines

In your CI workflow (GitHub Actions, GitLab CI, etc.), use Melos to bootstrap and run scripts in a cached environment. Example GitHub Actions snippet:

name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Flutter
        uses: subosito/flutter-action@v2
      - name: Install Melos
        run: flutter pub global activate melos
      - name: Bootstrap Monorepo
        run: melos bootstrap --no-utf-8
      - name: Run Analyzer
        run: melos run analyze
      - name: Run Tests
        run

Cache .pub-cache and ~/.pub-cache directories to speed up builds. This pipeline ensures consistent analysis, formatting, testing, and build steps across every package and app.

Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.

Conclusion

Melos brings order and automation to Flutter monorepos, making it easy to share code, enforce standards, and orchestrate workflows. By installing Melos, defining clear workspaces, and setting up scripts, you gain a centralized management layer for dependencies, tests, and builds. Integrating Melos into your CI/CD pipelines maintains consistency across projects and accelerates development velocity. Adopt Melos today to streamline your Flutter mobile development and unlock the full potential of monorepo architecture.

Build Flutter Apps Faster with Vibe Studio

Build Flutter Apps Faster with Vibe Studio

Build Flutter Apps Faster with Vibe Studio

Build Flutter Apps Faster with Vibe Studio

Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.

Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.

Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.

Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.

Other Insights

Other Insights

Other Insights

Other Insights

Join a growing community of builders today

Join a growing community of builders today

Join a growing community of builders today

Join a growing community of builders today

Join a growing community of builders today

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025

28-07 Jackson Ave

Walturn

New York NY 11101 United States

© Steve • All Rights Reserved 2025