Home / Insights / Mobile App Development

Mobile App Development

Flutter Architecture for Large Apps: Modules, Navigation and Testing That Scale with the Team

A Flutter app that starts as one project with a handful of screens can become hard to change once several teams, dozens of features and multiple release channels are involved. This guide sets out an architecture for large Flutter apps that keeps features independent, navigation predictable and tests worth running.

TopicsMobile App DevelopmentArchitecture and Modernization

Key takeaways

  • Flutter’s own architecture guide recommends separate UI and data layers (views, view models, repositories and services), with an optional domain layer only where logic is shared or complex.
  • Split a large app into feature packages with explicit public interfaces; Dart pub workspaces (Dart 3.6 and later) let a monorepo share one dependency resolution and lockfile.
  • Use the Router API through a package such as go_router once you need deep links, web URLs or nested navigation; the Flutter docs advise against named routes for most apps.
  • Build a test mix of many unit and widget tests and a small set of integration tests on critical journeys, and enforce module boundaries in CI.
  • Modularise incrementally: extract the core and one feature first, measure build and test times, and stop when boundaries match how teams actually work.

Flutter makes it quick to ship the first version of an app. The difficulty arrives later: a single lib/ folder with hundreds of files, state that leaks between screens, navigation logic spread across widgets, and a test suite that takes too long or catches too little. At that point every change feels risky, and adding developers slows the team down rather than speeding it up.

This article is for CTOs, mobile leads and product owners responsible for a Flutter app that is growing, or about to grow, beyond one small team. It covers how to layer the code, how to split it into modules, how to handle navigation and deep links, how to test at scale and how to migrate an existing app without stopping feature work. It draws on how our Flutter development team structures long-lived apps, including the mobile side of a care management platform for Australian disability and aged care providers.

When does a Flutter app need a deliberate architecture?

Not every app needs modules and layers from day one. A prototype or a small app with one developer can live comfortably in a single package. The signals that it is time to invest are practical rather than theoretical:

  • More than one team, or more than four or five developers, regularly edit the same files and conflict in code review.
  • A change in one feature breaks another that appears unrelated.
  • Build, analysis or test times have grown enough that developers avoid running them locally.
  • The same business logic, such as pricing or permissions, is implemented in several widgets.
  • The product now needs deep links, a web version, white-label variants or feature flags per market.

If two or more apply, the cost of not structuring the app is already being paid in slower delivery and regressions. The goal of the architecture below is not elegance; it is to let teams change one feature with confidence that others are unaffected.

How should the code be layered?

The official Flutter app architecture guide recommends separation of concerns as the main principle and describes two broad layers, which it presents as guidelines to adapt rather than strict rules.

UI layer: views and view models

Views are widget compositions that render state and forward user events. The guide says views should not contain business logic beyond simple conditions, layout and routing. View models turn application data into UI state and expose commands that views call. The guide suggests a one-to-one relationship between a view and its view model.

Data layer: repositories and services

Repositories are the source of truth for application data: they call services, cache, handle errors and retries, and output domain models. Services wrap a single external source such as a REST API, a platform plugin or local storage, and hold no state. The guide recommends that repositories do not depend on each other.

Optional domain layer

Use-cases are worth adding when logic combines several repositories, is complex, or is reused by several view models. The guide advises adding them only where needed rather than wrapping every data call, which is sound advice for large apps where needless indirection adds review and test effort.

ComponentOwnsMust notTested with
View (widgets)Layout, presentation, user eventsCall APIs or hold business rulesWidget tests
View modelUI state, commands, input validationImport Flutter UI widgets or talk to services directlyUnit tests with fake repositories
Use-case (optional)Logic across repositoriesHold UI stateUnit tests
RepositorySource of truth, caching, retries, domain modelsDepend on other repositoriesUnit tests with fake services
ServiceOne external data sourceHold stateContract or integration tests

State management libraries sit inside this structure rather than replacing it. Riverpod, Bloc or Provider can implement view models and dependency injection; the choice matters less than applying it consistently. We compare the options in choosing state management for a Flutter app.

How should a large app be split into modules?

Layers organise code inside a feature. Modules organise features against each other. In Dart, the natural module is a package with its own pubspec.yaml, a public API in its lib/ folder and private implementation under lib/src/.

A practical package layout

  • app: the shell. Entry points per flavour, dependency wiring, top-level router and theming. Contains very little logic.
  • core packages: networking client, authentication session, analytics, logging, configuration and feature flags. Kept small and stable.
  • design_system: tokens, themes and shared widgets. Owned by one team with a review process.
  • feature packages: one per business capability (for example onboarding, bookings, payments, messaging), each with its own views, view models, repositories and tests.
  • shared domain packages, only where several features genuinely share models or rules.

Dependency rules

  1. Features may depend on core and design_system, never on each other’s internals.
  2. Where one feature needs another, it depends on a small interface (for example a PaymentsLauncher) defined in a shared package and implemented by the owning feature.
  3. Only the app shell knows every feature and wires them together.

Monorepo tooling

According to the Dart pub workspaces documentation, workspaces, introduced in Dart 3.6, let several packages in one repository share a single dependency resolution, one pubspec.lock and one analysis context, which reduces IDE memory use and prevents packages drifting to different versions of the same dependency. Configuration is a workspace list in the root pubspec and resolution: workspace in each member. The trade-off is that conflicts must be resolved across the whole repository, and dependency overrides are best kept in the root.

ApproachSuitsProsCons
Single package, folders by featureOne team, under roughly 50 screensSimplest; no tooling overheadBoundaries rely on discipline; imports leak easily
Monorepo with feature packages and pub workspacesSeveral teams on one appEnforced boundaries; one lockfile; atomic changes across packagesUpfront restructuring; shared CI must stay fast
Separate repositories per packagePackages shared across several apps or organisationsIndependent versioning and ownershipVersion coordination and slower cross-cutting changes

For most product companies, the monorepo with feature packages is the right default once more than one team is involved.

Navigation is where modular apps most often fall apart, because screens in one feature push screens in another by importing them directly.

Navigator or Router

The Flutter navigation and routing documentation recommends the imperative Navigator for small apps without complex deep linking, and the Router API, usually through a package such as go_router, for apps that need deep links, direct web URLs or multiple navigators. It specifically does not recommend named routes for most apps, because deep-link behaviour cannot be customised and the browser forward button is not supported. It also notes that routes created with Navigator.push or dialogs are not deep-linkable, while page-backed routes from the Router are.

Patterns for modular navigation

  • Each feature exports its routes as a list of route definitions, and the app shell composes them into one router configuration.
  • Navigate by path or typed route objects, not by importing another feature’s widgets. Typed routes generated from path definitions catch broken parameters at compile time.
  • Keep redirects central. Authentication, onboarding and feature-flag redirects belong in the router configuration, not scattered in screens.
  • Use nested navigation for tabs so each tab keeps its own stack, and test what the back button does on Android and the web.
  • Treat deep links as a public API. Document supported paths, version them, and add integration tests for each, since marketing emails and notifications depend on them.

For example, an illustrative booking app might expose /bookings/:id from its bookings feature and /checkout from payments. The bookings screen calls a typed route to checkout without knowing how payments are implemented, and the shell redirects unauthenticated users to sign-in before either loads.

What testing strategy holds up at scale?

The Flutter testing overview describes three kinds of automated test and their trade-offs: unit tests are quick with few dependencies but give lower confidence; widget tests give more confidence at higher maintenance cost; integration tests, running on a device or emulator, give the highest confidence but are slowest and most expensive to maintain. Its recommendation is many unit and widget tests, tracked with coverage, plus enough integration tests to cover important use cases. It also notes that the SDK’s integration_test package cannot interact with native UI such as permission dialogs, and points to the patrol package for those cases.

How the architecture makes this affordable

  • View models and repositories are plain Dart, so they are unit tested with fakes, without widgets.
  • Widget tests cover each view in its key states (loading, empty, error, populated) using fake view models.
  • Each feature package runs its own tests, so CI can test only packages affected by a change.
  • Integration tests focus on revenue- or safety-critical journeys and every published deep link.

Guardrails in CI

  1. Static analysis with a shared lint configuration across all packages.
  2. A dependency check that fails the build if a feature imports another feature’s src/ folder.
  3. Unit and widget tests for affected packages on every pull request.
  4. Integration tests on emulators nightly and before release, with a small device-farm run for the critical paths.
  5. Golden tests for design system components, reviewed by the owning team.

Our article on test automation frameworks covers how to choose tooling around this pyramid.

How do you migrate an existing app without stopping delivery?

Rewrites rarely pay off. A staged extraction keeps features shipping while the structure improves.

  1. Measure the baseline. Record build time, analysis time, test time, flaky test rate and how often changes cause regressions in other features.
  2. Agree the target layout and dependency rules in a short architecture decision record, so reviewers can apply them consistently.
  3. Extract core and design_system first. These have the most dependants and the clearest boundaries.
  4. Move to the Router if you still use named routes or scattered Navigator.push calls, defining paths for existing screens before moving them.
  5. Extract one feature end to end, ideally one owned by a single team and under active development, and apply the layering inside it.
  6. Add the boundary check to CI once the first feature is extracted, so new code follows the rules.
  7. Repeat feature by feature, prioritising areas with the most change and the most regressions.

For example, a team of eight developers might spend part of each sprint on extraction over a quarter, rather than freezing features. If you inherited the codebase from another team, start with a structured technical review before planning the extraction.

What are the costs and risks of over- or under-engineering?

RiskSignResponse
Over-modularisationDozens of tiny packages, frequent cross-package changes for one featureMerge packages that always change together; align modules with team ownership
Abstraction for its own sakeUse-cases that only forward calls; interfaces with one implementation everywhereFollow the Flutter guide: add a domain layer only where logic is shared or complex
Leaky boundariesFeatures importing each other’s internalsAutomated dependency checks in CI; shared interfaces
Slow CIEvery change runs every testAffected-package testing; nightly full runs
Navigation regressionsDeep links from notifications open the wrong screenDeep links documented and covered by integration tests

The cost of a deliberate architecture sits mostly in the first restructuring and in review discipline. The return comes from faster onboarding, fewer cross-feature regressions and the ability to add developers without proportional coordination overhead. Our article on what drives the cost of a Flutter app covers where shared code saves effort and where it does not.

Checklist: is your Flutter app structured to scale?

  • Views contain no business logic; view models and repositories are plain Dart and unit tested.
  • Repositories are the single source of truth and do not depend on each other.
  • Features live in separate packages with a public API and private src/ implementation.
  • Features never import each other’s internals; CI enforces this.
  • The monorepo uses one dependency resolution, for example pub workspaces.
  • Navigation uses the Router API with routes exported per feature and redirects defined centrally.
  • Every supported deep link is documented and covered by an integration test.
  • The test suite has many unit and widget tests and a focused set of integration tests on critical journeys.
  • Build, analysis and test times are measured and reviewed each quarter.

Frequently asked questions

Do we need clean architecture packages like a separate domain layer for every feature?

No. Flutter’s own guidance treats the domain layer as optional and recommends adding use-cases only where logic spans repositories, is complex or is reused. Wrapping every call adds code and tests without adding safety.

Is go_router required for a large app?

Not strictly, but the Flutter documentation recommends the Router API, usually through a package such as go_router, for apps with deep links, web URLs or multiple navigators, and advises against named routes for most apps. Most large apps meet at least one of those conditions.

How many integration tests should we have?

Enough to cover the journeys that matter most, such as sign-in, purchase or booking, and each published deep link. Flutter’s guidance is to rely mainly on many unit and widget tests, because integration tests are slower and costlier to maintain.

Can we modularise without a monorepo?

Yes, but separate repositories add version coordination overhead. For a single app built by several teams, a monorepo with pub workspaces is usually simpler; separate repositories make sense when packages are shared across several apps.

How long does it take to restructure an existing app?

It depends on size and how tangled the current code is. A staged approach, extracting core packages and one feature first, lets you measure the effort on your own codebase before committing to a full plan, while feature delivery continues.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Flutter documentation: Guide to app architecture — accessed 9 November 2026. UI and data layers, views and view models, repositories as source of truth, stateless services, optional use-case layer and feature-based organisation.
  2. Flutter documentation: Navigation and routing — accessed 9 November 2026. Navigator versus Router, go_router recommendation, limitations of named routes, deep-linkable page-backed routes and web history integration.
  3. Flutter documentation: Testing Flutter apps — accessed 9 November 2026. Unit, widget and integration test trade-offs, recommended test mix and integration_test limitations with native UI.
  4. Dart documentation: Pub workspaces (monorepo support) — accessed 9 November 2026. Workspaces introduced in Dart 3.6, shared resolution and lockfile, configuration and limitations.

Is your Flutter codebase slowing your teams down?

We can review your app’s structure, navigation and tests, and plan a staged modularisation that keeps features shipping.