-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
When initializing Flutter asynchronously via FlutterMain.ensureInitializationCompleteAsync, the callback is never called if the engine is already initialized. This seems like unintended behavior, since the purpose of the function is to first ensure that initialization is completed, and after that's ensured run a piece of code.
Here's the line which returns without calling the callback:
https://github.com/flutter/engine/blob/2baba33c829703a1067072cd5c2c7fec1145a257/shell/platform/android/io/flutter/view/FlutterMain.java#L242-L244
In particular, I'd like to turn Flutter initialization into a coroutine:
suspendCoroutine<Unit> { continuation ->
FlutterMain.startInitialization(applicationContext)
val flutterShellArgs = FlutterShellArgs(arrayOf<String>())
val handler = Handler()
FlutterMain.ensureInitializationCompleteAsync(applicationContext, flutterShellArgs.toArray(), handler) {
continuation.resume(Unit)
}
}
But this coroutine won't resume if Flutter is already initialized (and I've found no way of checking if Flutter already is initialized as a workaround).
Am I approaching this wrong? Did I miss something?