Video on youtube explaining in detail how it works: https://www.youtube.com/watch?v=lPp978ImSkE
Article on medium explaining in detail how it works: https://medium.com/@FlavioAro/how-to-integrate-a-flutter-module-into-your-native-android-application-52c41eeb6154
to start the project access the AndroidApp project in Android Studio and do a 'sync'
File > Sync Project with Gradle Files
Integrate a Flutter module into your Android project: https://docs.flutter.dev/development/add-to-app/android/project-setup#manual-integration
Adding a Flutter screen to an Android app: https://docs.flutter.dev/development/add-to-app/android/add-flutter-screen?tab=default-activity-launch-kotlin-tab
flutter create -t module --org com.example flutter_module
flutter build aar
android {
buildTypes {
// ...
profile {
initWith debug
}
}
}
dependencies {
// ...
debugImplementation 'com.example.flutter_module:flutter_debug:1.0'
profileImplementation 'com.example.flutter_module:flutter_profile:1.0'
releaseImplementation 'com.example.flutter_module:flutter_release:1.0'
}
repositories {
// ...
maven {
url '../flutter_module/build/host/outputs/repo'
}
maven {
url "https://storage.googleapis.com/download.flutter.io"
}
}
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
/>
import io.flutter.embedding.android.FlutterActivity
Start the flutter module:
myButton.setOnClickListener {
startActivity(
FlutterActivity.createDefaultIntent(this)
)
}
Access a specific screen, through a route:
myButton.setOnClickListener {
startActivity(
FlutterActivity
.withNewEngine()
.initialRoute("/my_route")
.build(this)
)
}