Adding Flutter in Existing Android App
It’s sometimes not practical to rewrite your entire application in Flutter all at once. For those situations, Flutter can be integrated into your existing application piecemeal, as a library or module. That module can then be imported into your Android app to render a part of your app’s UI in Flutter.
So let's get Started with Integration
Step 1:
Let’s assume that you have an existing Android app at some/path/SomeApp
, and that you want your Flutter project as a sibling:
cd some/path/
flutter create -t module --org com.example flutter_project_name
Now It will show Flutter Project in some/path at the name of flutter_project_name
Step 2:
Adding Java 8 in App Gradle File
android {
//...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
Step 3:
Need to Include the Flutter module as a subproject in the Existing Android App settings.gradle
:
// Include the host app project.
include ':app' // assumed existing content
setBinding(new Binding([gradle: this])) // new
evaluate(new File( // new
settingsDir.parentFile, // new
'flutter_project_name/.android/include_flutter.groovy' // new
))
Step 4:
Need to Introduce an implementation
dependency on the Flutter module from your app:
dependencies {
implementation project(':flutter')
}
Step 5:
Sync the project and You are good to Go.
Finally We have Implemented the Flutter app in Existing Android App