Transform your Flutter application into an embeddable module for iOS, Android, React Native, React Web, and Angular — with type-safe Protocol Buffer communication.
dart pub add dev:flutter_embedding_cli
Experience Flutter embedded in real web frameworks. These demos show bidirectional communication in action.
Imagine you're developing an SDK with rich UI components — a payment flow, an onboarding wizard, a chat interface. Your clients build native iOS apps, Android apps, React Native apps, or web apps with React and Angular.
Without Flutter Embedding CLI: you'd build and maintain separate codebases for each platform — native Swift/Kotlin, React Native bridges, web components. That's 5+ implementations to keep in sync.
With Flutter Embedding CLI: build your SDK once in Flutter, then generate ready-to-distribute packages for every platform. Your clients integrate it like any other native library — they don't even need to know it's Flutter inside.
Flutter's official "add-to-app" approach is notoriously complex and painful to set up. It requires:
Flutter Embedding CLI eliminates this pain. With a single command, it generates production-ready modules with:
| Feature | Protocol Buffers | Pigeon |
|---|---|---|
| iOS & Android support | ✓ | ✓ |
| React Native support | ✓ | ✗ |
| Web (React/Angular) support | ✓ | ✗ |
| Built-in schema evolution | ✓ Excellent backward compatibility | Limited |
| Cross-platform code generation | ✓ One definition, all platforms | Native only |
Proto files generate Dart code plus native code for all platforms: iOS (Swift), Android (Java), React Native (TypeScript), React Web (TypeScript), and Angular Web (TypeScript).
Describe the communication between host and Flutter in Protocol Buffers — the CLI takes care of the rest.
Use Protocol Buffers to define your exact communication contract. Theme switching, user data, complex objects — the possibilities are endless.
Define services for Flutter-to-host and host-to-Flutter calls. Both directions are fully type-safe with generated code.
Write your proto once, get type-safe clients and services generated for Dart, Swift, Java, and TypeScript automatically.
Web platforms support multiple Flutter views within the same application, each with independent communication channels.
Pass structured initialization data when launching Flutter. Define your StartParams message in proto — include whatever your app needs.
Generates CocoaPods or a Swift package for iOS, AAR for Android, and npm packages for web — ready for distribution to your teams.
CocoaPods or Swift Package Manager
AAR module
Cross-platform module
npm package
npm package
Add flutter_embedding to your pubspec.yaml and define your proto handovers for type-safe communication.
Run a single CLI command to generate modules for your target platforms with example apps.
Import the generated package into your host application and start communicating with Flutter.
# Install the CLI dart pub add dev:flutter_embedding_cli # Generate iOS module with example app dart run flutter_embedding_cli:generate ios --example # Generate Android module with example app dart run flutter_embedding_cli:generate android --example # Generate React Native module with example app dart run flutter_embedding_cli:generate react-native --example # Generate React web module with example app dart run flutter_embedding_cli:generate web-react --example # Generate Angular web module with example app dart run flutter_embedding_cli:generate web-angular --example
// Define what the host can call on Flutter service HandoversToFlutter { rpc SetTheme(ThemeRequest) returns (Empty); rpc UpdateUser(UserData) returns (Empty); rpc NavigateTo(Route) returns (Empty); } message StartParams { string environment = 1; string auth_token = 2; UserData user = 3; }
// Define what Flutter can call on the host service HandoversToHost { rpc Exit(Empty) returns (Empty); rpc ShareContent(ShareRequest) returns (Empty); rpc GetDeviceInfo(Empty) returns (DeviceInfo); rpc OpenPayment(PaymentRequest) returns (PaymentResult); } // Define any message types you need message PaymentRequest { string product_id = 1; int32 amount = 2; }
Define your services and messages in proto files — the CLI generates type-safe code for all platforms automatically.
By default the iOS SDK is packaged for CocoaPods: podspecs plus a podhelper that link the Debug frameworks in Debug builds and the Release frameworks in Release builds of the host app.
Host team moved on from CocoaPods? Set package_manager:
swift_package_manager and the CLI generates a local Swift package wrapping all
Flutter xcframeworks instead — and the example app becomes a plain Xcode project that
references that package. No Podfile, no pod install: add the package, build, done.
Swift Package Manager cannot switch frameworks per build configuration, so the package ships hybrid XCFrameworks: the device slice is the Release (AOT) build and the simulator slice is the Debug (JIT) build. Physical devices always run at full speed and simulators stay debuggable, whatever the host app's build configuration.
flutter_embedding: ios: # cocoapods (default) or swift_package_manager package_manager: swift_package_manager
Open source, MIT licensed, and shipped with example apps for every platform. Questions or ideas? Issues and PRs are welcome.