You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 2.0.0 Flutter release drastically reduces the memory footprint of additional Flutter engines from ~19MB on Android and ~13MB on iOS, to ~180kB on Android and iOS. This ~99% fixed cost reduction allows the multiple Flutters pattern to be used more liberally in your add-to-app integration.
Here's a basic guide on how to use multiple Flutters in both Android and iOS projects:
For Android:
Add Flutter to Your Project:
Ensure you have Flutter integrated into your existing Android project. Follow the official guide if you haven't done this yet.
Use FlutterEngineGroup: FlutterEngineGroup is a class that manages multiple FlutterEngine instances. You can create a single FlutterEngineGroup and use it to spawn multiple FlutterEngine instances.
Example:
FlutterEngineGroupengineGroup = newFlutterEngineGroup(context);
// Create a FlutterEngine for a specific entrypoint or Dart fileFlutterEngineflutterEngine = engineGroup.createAndRunEngine(context, entrypoint);
Display Flutter UI:
Use FlutterActivity or FlutterFragment to display the UI rendered by a FlutterEngine. Each instance can run different Dart entrypoints or the same entrypoint with different initial routes.
Isolation: Each Flutter instance is isolated from others, meaning they do not share Dart execution contexts or memory.
Performance Consideration: Be mindful of the resource usage when spawning multiple Flutter instances, as each instance consumes memory and CPU.
Use Cases: This approach is ideal for apps that need to display multiple Flutter screens simultaneously, or apps that integrate Flutter incrementally.
For more detailed information and the latest updates, refer to the Flutter documentation and the multiple_flutters module in the official Flutter samples repository.
The text was updated successfully, but these errors were encountered:
see here: https://docs.flutter.dev/add-to-app/multiple-flutters
sample code: https://github.com/flutter/samples/tree/master_archived/add_to_app/multiple_flutters
Here's a basic guide on how to use multiple Flutters in both Android and iOS projects:
For Android:
Add Flutter to Your Project:
Ensure you have Flutter integrated into your existing Android project. Follow the official guide if you haven't done this yet.
Use FlutterEngineGroup:
FlutterEngineGroup
is a class that manages multipleFlutterEngine
instances. You can create a singleFlutterEngineGroup
and use it to spawn multipleFlutterEngine
instances.Example:
Display Flutter UI:
Use
FlutterActivity
orFlutterFragment
to display the UI rendered by aFlutterEngine
. Each instance can run different Dart entrypoints or the same entrypoint with different initial routes.Example:
For iOS:
Add Flutter to Your Project:
Integrate Flutter into your existing iOS project following the official integration guide.
Use FlutterEngineGroup:
On iOS, use
FlutterEngineGroup
to manage multipleFlutterEngine
instances.Example:
Display Flutter UI:
Use a
FlutterViewController
to display the Flutter content. EachFlutterEngine
can be attached to its ownFlutterViewController
.Example:
Notes:
For more detailed information and the latest updates, refer to the Flutter documentation and the multiple_flutters module in the official Flutter samples repository.
The text was updated successfully, but these errors were encountered: