Sub topic 1
What add-to-app is and when to choose it
Prerequisites
This chapter assumes that you know basic Flutter and Dart, including widgets and the flutter command. You should also understand either Android development with Kotlin or Java, or iOS development with Swift or Objective-C. Familiarity with Gradle or CocoaPods will help when you connect the Flutter code to the native build.
The add-to-app model
Flutter add-to-app means embedding Flutter UI inside an existing native application. The native application remains the main product and controls its existing screens, navigation, authentication, storage, and platform services. Flutter supplies one or more screens or features.
A Flutter module is a reusable Flutter project without its own standalone native application. The Android or iOS host imports that module, starts a Flutter engine, and displays Flutter widgets in a native screen.
The integration has three important parts:
- The native host is the existing Android or iOS application.
- A
FlutterEngineruns Dart code and renders Flutter widgets. - A native Flutter view displays the rendered result inside an Activity or view controller.
The host and Flutter code can exchange data through platform channels. For example, the host can provide a logged-in user's name, while Flutter can ask the host to open a native payment screen.
flowchart TD
Host[Existing native app] --> Engine[FlutterEngine]
Engine --> Dart[Dart and Flutter widgets]
Engine --> View[Flutter view]
Host <--> Channel[Platform channel]
Channel <--> DartAdd-to-app versus a full rewrite
A full rewrite moves most or all product behavior to Flutter. That can produce a consistent cross-platform UI, but it requires migrating existing features and accepting a large release risk.
Add-to-app limits the migration boundary. You can build a new feature in Flutter while leaving stable native features unchanged. You can then expand the Flutter area after measuring its results.
| Approach | Best fit | Main cost |
|---|---|---|
| Add-to-app | A mature native app needs selected cross-platform features | Integration and duplicated platform boundaries |
| Full Flutter application | A new product or a product ready for broad migration | Large initial rewrite and migration risk |
| Native-only development | Platform-specific behavior dominates the product | Separate UI and feature work for each platform |
Choose add-to-app when at least one of these conditions is true:
- You need one implementation for a feature used on Android and iOS.
- The existing native app has valuable code that should remain in place.
- A team wants to adopt Flutter gradually.
- You need to test Flutter in production without replacing the entire application.
- A new, visually rich flow can be isolated behind a clear native boundary.
Avoid it when the feature depends heavily on native UI conventions, native accessibility behavior that Flutter cannot yet match for your needs, or deep access to platform-specific services. It can also be a poor choice when the team cannot support both Flutter and the existing native stack during the transition.
Define the integration boundary
Before creating a module, decide which system owns each responsibility. A useful boundary often looks like this:
- Native code owns login sessions, secure storage, push notifications, and existing navigation.
- Flutter owns the screens, widget state, form validation, and presentation logic for the new feature.
- A small interface carries data and commands across the boundary.
Keep that interface explicit. Passing a stable data object is easier to maintain than letting Dart call many unrelated native APIs. The boundary should also define error behavior, loading states, and ownership of updates.
> callout note > Add-to-app is an architectural choice, not only a build setting. A small, well-defined Flutter feature is easier to integrate, test, and remove than a feature that reaches into many native services.
A gradual adoption path
A typical migration proceeds in stages:
- Create a Flutter module beside the native application.
- Embed one Flutter screen in a development build.
- Connect only the data that screen needs.
- Measure startup time, memory use, crash behavior, and user experience.
- Add more Flutter screens if the boundary remains manageable.
- Move shared flows only when the operational benefits exceed the integration cost.
The first Flutter screen may start slowly because the engine must initialize. Later screens can reuse a pre-warmed engine. This improves responsiveness but increases memory use and lifecycle complexity, so measure both effects.
When to choose another approach
Use native development when the feature must closely follow platform design systems or depends on specialized native SDKs. Consider a full Flutter application when most product surfaces are new, cross-platform, and expected to share one UI architecture. Consider a web view only when the feature already exists as a web product and native integration is intentionally minimal.
Exercise
A native shopping app needs a new account-settings flow for Android and iOS, while its authentication and secure storage are already stable. Which approach is a reasonable first choice, and what boundary should you define?
Show answer
Use add-to-app. Let Flutter own the account-settings screens and local presentation state, while the native host owns authentication and secure storage. Expose a small interface for reading the current user and saving approved settings.