Here's what I've done in IntelliJ:
- Created a Kotlin Mobile Library named "backend".
- Create a Flutter project named "frontend".
- Created an empty IntelliJ project and dumped both projects inside.
I am able to build each project individually and run my frontend in an emulator. My goal here is to use Dart MethodChannels so that I can have my Kotlin library do all of the heavy lifting + business logic, while Flutter/Dart just render UI. In addition to all of the Gradle- and IntelliJ-related headaches (Kotlin DSL vs Groovy, etc.) I've run into in the past 1.5 days of working on this, I'm doubting this strategy, as I'm having trouble finding good examples or discussion of what I'm trying to accomplish. (I'm aware of the Flutter platform_channel example, but that directly integrates the Kotlin into the Android subproject, and I'm trying to completely isolate my frontend from the backend.)
Ideally, both projects would eventually be managed by the same build.gradle.kts as subprojects, and properly depend upon each other in an idiomatic Gradle fashion. For the time being, I'm working around this by using the following task in the Android portion of my backend:
tasks.register<Copy>("copyAAR") {
from("$buildDir/outputs/aar")
into("../frontend/android/app/src/main/libs")
}
And then my frontend Android Dart task (in IntelliJ) depends upon backend:android:assemble and backend:android:copyAAR. (I have not yet successfully included the appropriate debug/release AAR into my Flutter project via Gradle and used it.)
I'd accept answers to any of the following:
- Does my strategy seem reasonable or is there a better way?
- Can someone point me to a concrete example of what I'm trying to accomplish?