Embedding Flutter in Existing iOS and Android Apps
May 28, 2025



Summary
Summary
Summary
Summary
This tutorial explores integrating Flutter modules into existing native apps, managing engine lifecycles, and bridging platforms via MethodChannel, enabling teams to reuse Flutter’s expressive UI within iOS and Android hosts without full rewrites.
This tutorial explores integrating Flutter modules into existing native apps, managing engine lifecycles, and bridging platforms via MethodChannel, enabling teams to reuse Flutter’s expressive UI within iOS and Android hosts without full rewrites.
This tutorial explores integrating Flutter modules into existing native apps, managing engine lifecycles, and bridging platforms via MethodChannel, enabling teams to reuse Flutter’s expressive UI within iOS and Android hosts without full rewrites.
This tutorial explores integrating Flutter modules into existing native apps, managing engine lifecycles, and bridging platforms via MethodChannel, enabling teams to reuse Flutter’s expressive UI within iOS and Android hosts without full rewrites.
Key insights:
Key insights:
Key insights:
Key insights:
Module Embedding: Use the Flutter module template and Pod integration for iOS.
Android Integration: Leverage Gradle and cached engines for seamless Android launches.
Engine Lifecycle: Cache engines for faster loads and better performance.
MethodChannel: Enables platform-Dart interop for bi-directional communication.
Performance Profiling: Use DevTools to optimize engine and isolate usage.
Vibe Studio: No-code Flutter integration and Firebase backends for rapid development.
Introduction
Embedding Flutter within existing native applications has become a powerful approach for teams looking to introduce new, high-performance UI without a full rewrite. The Flutter add-to-app pattern enables you to integrate Flutter modules into both iOS and Android hosts, leveraging Dart’s reactive framework alongside your established codebase. This tutorial dives into advanced steps for seamless add to app workflows, engine lifecycle management, and platform interop.
Integrating Flutter into iOS
To embed a Flutter module into an existing Xcode project:
• Generate the Flutter module: Run flutter create --template module my_flutter
in your host repo.
• Add the Pod dependency. In your iOS project’s Podfile:
flutter_application_path = '../my_flutter'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'YourApp' do
install_all_flutter_pods(flutter_application_path)
end
Then execute pod install
.
• Initialize and present the Flutter engine. In AppDelegate.swift:
import Flutter
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var flutterEngine = FlutterEngine(name: "my_engine")
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
flutterEngine.run()
return true
}
}
To display Flutter:
let flutterViewController = FlutterViewController(engine: appDelegate.flutterEngine, nibName: nil, bundle: nil)
navigationController?.pushViewController(flutterViewController, animated: true)
Tip: Cache the FlutterEngine for faster cold-start times. Avoid recreating the engine on every presentation if you need persistent state.
Integrating Flutter into Android
On Android, use Gradle to import the module and then launch a FlutterActivity or FlutterFragment.
• Include the module in settings.gradle:
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'my_flutter/.android/include_flutter.groovy'))
• Add dependency in app/build.gradle:
implementation project(':flutter')
• Launch Flutter from MainActivity:
import io.flutter.embedding.android.FlutterActivity
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Button(this).apply {
text = "Open Flutter"
setOnClickListener {
startActivity(
FlutterActivity
.withCachedEngine("my_engine_id")
.build(this@MainActivity)
)
}
}.also { setContentView(it
• Pre-warm the engine in Application:
class MyApp: Application() {
override fun onCreate() {
super.onCreate()
FlutterEngine(this).apply {
dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
// Cache this engine
FlutterEngineCache
.getInstance()
.put("my_engine_id", this
Host-Framework Communication
Interoperability is central to the add-to-app use case. MethodChannel provides a bidirectional bridge for invoking platform code from Dart and vice versa.
Dart side:
import 'package:flutter/services.dart';
class HostApi {
static const _channel = MethodChannel('com.example/host');
Future<String> getBatteryLevel() async {
final String level = await _channel.invokeMethod('getBatteryLevel');
return level;
}
}
iOS side (AppDelegate.swift):
let channel = FlutterMethodChannel(name: "com.example/host",
binaryMessenger: flutterViewController.binaryMessenger)
channel.setMethodCallHandler { call, result in
if call.method == "getBatteryLevel" {
let level = UIDevice.current.batteryLevel * 100
result("\(Int(level))%")
} else {
result(FlutterMethodNotImplemented)
}
}
Android side (MainActivity.kt):
FlutterMethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.example/host")
.setMethodCallHandler { call, result ->
when (call.method) {
"getBatteryLevel" -> {
val batteryLevel = getBatteryLevel()
result.success("$batteryLevel%")
}
else -> result.notImplemented
Engine Lifecycle and Performance
Efficient engine management prevents memory bloat and reduces startup latency:
• Cache and reuse FlutterEngine instances across multiple entry points.
• Dispose of engines only when no longer needed, such as on Activity/UIViewController deinit.
• Profile performance with Flutter’s DevTools—identify jank, excessive rebuilds, or Dart isolate overhead.
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
Mastering the Flutter add-to-app workflow unlocks rapid feature delivery and a unified UI across platforms without discarding existing investments. By carefully integrating the module, managing engine lifecycle, and implementing robust MethodChannels, you can incrementally enrich native apps with Flutter’s expressive toolkit. Apply these advanced patterns to elevate your hybrid architecture and maintain peak performance.
Introduction
Embedding Flutter within existing native applications has become a powerful approach for teams looking to introduce new, high-performance UI without a full rewrite. The Flutter add-to-app pattern enables you to integrate Flutter modules into both iOS and Android hosts, leveraging Dart’s reactive framework alongside your established codebase. This tutorial dives into advanced steps for seamless add to app workflows, engine lifecycle management, and platform interop.
Integrating Flutter into iOS
To embed a Flutter module into an existing Xcode project:
• Generate the Flutter module: Run flutter create --template module my_flutter
in your host repo.
• Add the Pod dependency. In your iOS project’s Podfile:
flutter_application_path = '../my_flutter'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'YourApp' do
install_all_flutter_pods(flutter_application_path)
end
Then execute pod install
.
• Initialize and present the Flutter engine. In AppDelegate.swift:
import Flutter
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var flutterEngine = FlutterEngine(name: "my_engine")
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
flutterEngine.run()
return true
}
}
To display Flutter:
let flutterViewController = FlutterViewController(engine: appDelegate.flutterEngine, nibName: nil, bundle: nil)
navigationController?.pushViewController(flutterViewController, animated: true)
Tip: Cache the FlutterEngine for faster cold-start times. Avoid recreating the engine on every presentation if you need persistent state.
Integrating Flutter into Android
On Android, use Gradle to import the module and then launch a FlutterActivity or FlutterFragment.
• Include the module in settings.gradle:
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'my_flutter/.android/include_flutter.groovy'))
• Add dependency in app/build.gradle:
implementation project(':flutter')
• Launch Flutter from MainActivity:
import io.flutter.embedding.android.FlutterActivity
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Button(this).apply {
text = "Open Flutter"
setOnClickListener {
startActivity(
FlutterActivity
.withCachedEngine("my_engine_id")
.build(this@MainActivity)
)
}
}.also { setContentView(it
• Pre-warm the engine in Application:
class MyApp: Application() {
override fun onCreate() {
super.onCreate()
FlutterEngine(this).apply {
dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
// Cache this engine
FlutterEngineCache
.getInstance()
.put("my_engine_id", this
Host-Framework Communication
Interoperability is central to the add-to-app use case. MethodChannel provides a bidirectional bridge for invoking platform code from Dart and vice versa.
Dart side:
import 'package:flutter/services.dart';
class HostApi {
static const _channel = MethodChannel('com.example/host');
Future<String> getBatteryLevel() async {
final String level = await _channel.invokeMethod('getBatteryLevel');
return level;
}
}
iOS side (AppDelegate.swift):
let channel = FlutterMethodChannel(name: "com.example/host",
binaryMessenger: flutterViewController.binaryMessenger)
channel.setMethodCallHandler { call, result in
if call.method == "getBatteryLevel" {
let level = UIDevice.current.batteryLevel * 100
result("\(Int(level))%")
} else {
result(FlutterMethodNotImplemented)
}
}
Android side (MainActivity.kt):
FlutterMethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.example/host")
.setMethodCallHandler { call, result ->
when (call.method) {
"getBatteryLevel" -> {
val batteryLevel = getBatteryLevel()
result.success("$batteryLevel%")
}
else -> result.notImplemented
Engine Lifecycle and Performance
Efficient engine management prevents memory bloat and reduces startup latency:
• Cache and reuse FlutterEngine instances across multiple entry points.
• Dispose of engines only when no longer needed, such as on Activity/UIViewController deinit.
• Profile performance with Flutter’s DevTools—identify jank, excessive rebuilds, or Dart isolate overhead.
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
Mastering the Flutter add-to-app workflow unlocks rapid feature delivery and a unified UI across platforms without discarding existing investments. By carefully integrating the module, managing engine lifecycle, and implementing robust MethodChannels, you can incrementally enrich native apps with Flutter’s expressive toolkit. Apply these advanced patterns to elevate your hybrid architecture and maintain peak performance.
Elevate Your App with Vibe Studio
Elevate Your App with Vibe Studio
Elevate Your App with Vibe Studio
Elevate Your App with Vibe Studio
Build and deploy stunning Flutter modules—no native code required—with Vibe Studio’s powerful AI-driven workflows.
Build and deploy stunning Flutter modules—no native code required—with Vibe Studio’s powerful AI-driven workflows.
Build and deploy stunning Flutter modules—no native code required—with Vibe Studio’s powerful AI-driven workflows.
Build and deploy stunning Flutter modules—no native code required—with Vibe Studio’s powerful AI-driven workflows.
Join a growing community of builders today
Join a growing
community
of builders today
Join a growing
community
of builders today










© Steve • All Rights Reserved 2025


© Steve • All Rights Reserved 2025


© Steve • All Rights Reserved 2025


© Steve • All Rights Reserved 2025