A Flutter module SDK that can be embedded into existing iOS and Android applications as prebuilt frameworks. This SDK provides a complete Flutter-based UI with API integration, dependency injection, and seamless integration with native apps.
This repository contains a Flutter SDK module that can be integrated into native iOS and Android applications. The SDK is designed to be distributed as prebuilt frameworks (iOS) and AAR files (Android), allowing teams to integrate Flutter functionality without requiring all developers to have the Flutter toolchain installed.
For Android integration, the Flutter AAR files are distributed via a separate Maven repository hosted on GitHub Pages. See the Maven Repository Documentation for detailed information about Maven repository hosting, distribution, and usage.
flutter_sdk_repo/
├── flutter_sdk/ # Flutter module source code
│ ├── lib/
│ │ ├── models/ # Data models (Post, Counter, etc.)
│ │ ├── services/ # Business logic and API services
│ │ ├── views/ # UI screens and widgets
│ │ ├── main.dart # Embedded mode entry point
│ │ └── main_standalone.dart # Standalone mode entry point
│ └── assets/ # Lottie animations and other assets
├── ios-example/ # iOS SwiftUI example app
└── example_android/ # Android example app
- ✅ Prebuilt Framework Support: Distribute as prebuilt frameworks/AARs
- ✅ Dependency Injection: Uses GetIt for service management
- ✅ API Integration: Built-in HTTP client with Dio
- ✅ Dual Mode Support: Embedded (MethodChannel) and Standalone modes
- ✅ Modern UI: Lottie animations, Material Design
- ✅ Error Handling: Comprehensive error handling with retry mechanisms
- ✅ State Management: Provider pattern for reactive UI
To build the Flutter module as prebuilt frameworks/AARs:
For iOS:
cd flutter_sdk
flutter pub get
flutter build ios-framework --xcframework --output=../ios-example/FlutterFor Android:
cd flutter_sdk
flutter pub get
flutter build aarThis will generate frameworks/AARs for Debug, Profile, and Release configurations.
Once the Flutter module is linked into your application, you're ready to fire up an instance of the Flutter engine and present the Flutter view controller.
Download the prebuilt Flutter frameworks and add them to your Xcode project:
- Open the
Flutter/Releasedirectory (or Debug/Profile based on your build configuration) - Drag
App.xcframeworkandFlutter.xcframeworkto the General > Frameworks, Libraries, and Embedded Content section of your app target in Xcode - Ensure both frameworks are set to "Embed & Sign"
Create new AppDelegate.swift, instantiate and run the Flutter engine:
import UIKit
import Flutter
class AppDelegate: UIResponder, UIApplicationDelegate {
var flutterEngine: FlutterEngine?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Instantiate Flutter engine
self.flutterEngine = FlutterEngine(name: "io.flutter", project: nil)
self.flutterEngine?.run(withEntrypoint: nil)
return true
}
}For SwiftUI apps, use @UIApplicationDelegateAdaptor:
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}In any ViewController (typically in response to a button press), present the Flutter module's UI:
let flutterEngine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
present(flutterViewController, animated: true, completion: nil)Once executed, the Flutter UI will appear in your app!
For more detailed instructions, see ios-example/README.md.
Once the Flutter module is linked into your application, you need to fire up an instance of the Flutter engine and present the Flutter Activity.
Add the AAR repository and dependencies in your app/build.gradle. The Flutter AAR files are hosted in a separate Maven repository:
repositories {
maven {
// Maven repository hosted on GitHub Pages
url 'https://iamnabink.github.io/flutter-android-sdk-maven-repo'
// url '../../flutter_sdk/build/host/outputs/repo'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
google()
mavenCentral()
}For more information about the Maven repository structure, hosting, and alternative setup options, see the Maven Repository Documentation.
Add Dependencies:
dependencies {
releaseImplementation ('dev.nabrajkhadka.example.flutter_module:flutter_release:1.0@aar') {
transitive = true
}
debugImplementation ('dev.nabrajkhadka.example.flutter_module:flutter_debug:1.0@aar') {
transitive = true
}
implementation 'androidx.multidex:multidex:2.0.1'
}Add the Flutter embedding metadata inside your <application> tag:
<meta-data
android:name="flutterEmbedding"
android:value="2" />Also add the FlutterActivity:
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true" />In your app's Application class, instantiate and cache a running Flutter engine. This pre-warms the engine for better performance:
import androidx.multidex.MultiDexApplication
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.embedding.engine.dart.DartExecutor
const val ENGINE_ID = "1" // or any unique identifier
class MyApplication : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
// Instantiate a FlutterEngine
val flutterEngine = FlutterEngine(this)
// Start executing Dart code to pre-warm the FlutterEngine
flutterEngine.dartExecutor.executeDartEntrypoint(
DartExecutor.DartEntrypoint.createDefault()
)
// Cache the FlutterEngine to be used by FlutterActivity
FlutterEngineCache.getInstance().put(ENGINE_ID, flutterEngine)
}
}
#### Step 4: Launch Flutter Activity
In any Activity class (typically in response to a button press or other UI event), launch the Flutter module's UI:
```kotlin
import io.flutter.embedding.android.FlutterActivity
// In your Activity's onCreate or button click handler
val intent = FlutterActivity
.withCachedEngine(ENGINE_ID)
.build(this)
startActivity(intent)Example from MainActivity:
button.setOnClickListener {
val intent = FlutterActivity
.withCachedEngine(ENGINE_ID)
.build(this)
startActivity(intent)
}Once executed, the Flutter UI will appear in your app!
For more detailed instructions, see example_android/README.md.
The Flutter SDK uses a clean architecture pattern:
- Models: Data classes with Equatable for value comparison
- Services: Business logic and API communication
- Views: UI components and screens
- Dependency Injection: GetIt for service registration
- Counter Service: Demonstrates MethodChannel communication (embedded mode) or local state (standalone mode)
- Posts Service: API integration example using Dio
- Posts View: List view with pull-to-refresh and error handling
- Details Page: Detail view with API integration
The SDK can run in standalone mode for development/testing:
cd flutter_sdk
flutter pub get
flutter runOr use the VS Code launch configurations in .vscode/launch.json.
- Flutter SDK: 3.9.0 or higher
- iOS:
- Xcode 14.0+
- iOS 12.4+
- Android:
- Android Studio
- minSdkVersion 24+
Packing Multiple Flutter Libraries: In add-to-app setups, it's essential to understand that packing multiple Flutter libraries into an application isn't directly supported. Each Flutter module is typically integrated into a specific native app module, and there may be challenges when attempting to include multiple Flutter modules within the same native app.
Performance Overhead: While Flutter provides excellent performance out-of-the-box, integrating Flutter into an existing app may introduce additional performance overhead, especially if not optimised properly.
Testing and Debugging: Testing and debugging can be more challenging in an add-to-app setup, especially when dealing with issues that span both Flutter and native code.
Support for AndroidX: In add-to-app setups on Android, the Flutter module only supports AndroidX applications. AndroidX is the modern Android library suite that replaces the now-deprecated Android Support Libraries.
The Flutter SDK uses the following key dependencies:
provider: State managementget_it: Dependency injectiondio: HTTP clientdartz: Functional programming utilitiesequatable: Value equalitylottie: Animations
- Clone the repository
- Navigate to
flutter_sdk/ - Run
flutter pub get - Open in your preferred IDE (VS Code or Android Studio)
When ready to distribute:
- Build frameworks/AARs for all configurations (Debug, Profile, Release)
- Distribute the prebuilt files to your team
- Teams can integrate without Flutter SDK installed
- Flutter SDK README - Detailed Flutter module documentation
- iOS Example README - iOS SwiftUI integration guide
- Android Example README - Android integration guide
- Official Flutter reference
Copyright © 2026 Nabraj Khadka
For issues and questions, please refer to the individual README files in each example directory or check the Flutter add-to-app documentation.