Using a pre-warmed FlutterEngine

By default, a FlutterFragment creates its own instance
of a FlutterEngine, which requires non-trivial warm-up time.
This means your user sees a blank Fragment for a brief moment.
You can mitigate most of this warm-up time by
using an existing, pre-warmed instance of FlutterEngine.

To use a pre-warmed FlutterEngine in a FlutterFragment,
instantiate a FlutterFragment with the withCachedEngine()
factory method.

Java

Kotlin

// Somewhere in your app, before your FlutterFragment is needed,

// like in the Application class ...

// Instantiate a FlutterEngine.

FlutterEngine

flutterEngine

new

FlutterEngine

context

);

// Start executing Dart code in the FlutterEngine.