| Flutter iOS Embedder |

Instance Methods | List of all members
FlutterEngineGroup Class Reference

`#import <FlutterEngineGroup.h>`

Inheritance diagram for FlutterEngineGroup:

## Instance Methods
(instancetype) | - NS_UNAVAILABLE
(instancetype) | - initWithName:project:
(FlutterEngine *) | - makeEngineWithEntrypoint:libraryURI:
(FlutterEngine *) | - makeEngineWithEntrypoint:libraryURI:initialRoute:
(FlutterEngine *) | - makeEngineWithOptions:

## Detailed Description

Represents a collection of FlutterEngines who share resources which allows them to be created with less time const and occupy less memory than just creating multiple FlutterEngines.

Deleting a FlutterEngineGroup doesn't invalidate existing FlutterEngines, but it eliminates the possibility to create more FlutterEngines in that group.

Warning
  This class is a work-in-progress and may change.

See also
  https://github.com/flutter/flutter/issues/72009

Definition at line 56 of file FlutterEngineGroup.h.

## Method Documentation

## ◆ initWithName:project:

- (instancetype) initWithName: |  | (NSString*) | name
project: |  | (nullable FlutterDartProject*) | NS_DESIGNATED_INITIALIZER

Initialize a new FlutterEngineGroup.

Parameters

  name | The name that will present in the threads shared across the engines in this group.
  project | The `FlutterDartProject` that all FlutterEngines in this group will be executing.

Definition at line 17 of file FlutterEngineGroup.mm.

22 :(NSString*)name project:(nullable FlutterDartProject*)project {
23 self = [super init];
24 if (self) {
25 _name = [name copy];
26 _engines = [NSPointerArray weakObjectsPointerArray];
27 _project = project;
28 }
29 return self;
30 }
_name
NSString * _name
Definition: FlutterChannels.mm:68
FlutterDartProject
Definition: FlutterDartProject.mm:268

## ◆ makeEngineWithEntrypoint:libraryURI:

- (FlutterEngine *) makeEngineWithEntrypoint: |  | (nullable NSString*) | entrypoint
libraryURI: |  | (nullable NSString*) | libraryURI

Creates a running `FlutterEngine` that shares components with this group.

Parameters

  entrypoint | The name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the method is not tree-shaken by the Dart compiler.
  libraryURI | The URI of the Dart library which contains the entrypoint method. IF nil, this will default to the same library as the `main()` function in the Dart program.

See also
  FlutterEngineGroup

Definition at line 17 of file FlutterEngineGroup.mm.

32 :(nullable NSString*)entrypoint
33 libraryURI:(nullable NSString*)libraryURI {
34 return [self makeEngineWithEntrypoint:entrypoint libraryURI:libraryURI initialRoute:nil];
35 }

## ◆ makeEngineWithEntrypoint:libraryURI:initialRoute:

- (FlutterEngine *) makeEngineWithEntrypoint: |  | (nullable NSString*) | entrypoint
libraryURI: |  | (nullable NSString*) | libraryURI
initialRoute: |  | (nullable NSString*) | initialRoute

Creates a running `FlutterEngine` that shares components with this group.

Parameters

  entrypoint | The name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the method is not tree-shaken by the Dart compiler.
  libraryURI | The URI of the Dart library which contains the entrypoint method. IF nil, this will default to the same library as the `main()` function in the Dart program.
  initialRoute | The name of the initial Flutter `Navigator` `Route` to load. If this is FlutterDefaultInitialRoute (or nil), it will default to the "/" route.

See also
  FlutterEngineGroup

Definition at line 17 of file FlutterEngineGroup.mm.

37 :(nullable NSString*)entrypoint
38 libraryURI:(nullable NSString*)libraryURI
39 initialRoute:(nullable NSString*)initialRoute {
40 FlutterEngineGroupOptions* options = [[FlutterEngineGroupOptions alloc] init];
41 options.entrypoint = entrypoint;
42 options.libraryURI = libraryURI;
43 options.initialRoute = initialRoute;
44 return [self makeEngineWithOptions:options];
45 }
FlutterEngineGroupOptions
Definition: FlutterEngineGroup.h:17
FlutterEngineGroupOptions::initialRoute
NSString * initialRoute
Definition: FlutterEngineGroup.h:36
FlutterEngineGroupOptions::libraryURI
NSString * libraryURI
Definition: FlutterEngineGroup.h:30
FlutterEngineGroupOptions::entrypoint
NSString * entrypoint
Definition: FlutterEngineGroup.h:24

## ◆ makeEngineWithOptions:

- (FlutterEngine *) makeEngineWithOptions: |  | (nullable FlutterEngineGroupOptions*) | options |

Creates a running `FlutterEngine` that shares components with this group.

Parameters

  options | Options that control how a FlutterEngine should be created.

See also
  FlutterEngineGroupOptions

Definition at line 17 of file FlutterEngineGroup.mm.

47 :(nullable FlutterEngineGroupOptions*)options {
48 NSString* entrypoint = options.entrypoint;
49 NSString* libraryURI = options.libraryURI;
50 NSString* initialRoute = options.initialRoute;
51 NSArray<NSString*>* entrypointArgs = options.entrypointArgs;
52
53 FlutterEngine* engine;
54 // NSPointerArray is clever and assumes that unless a mutation operation has occurred on it that
55 // has set one of its values to nil, nothing could have changed and it can skip compaction.
56 // That's reasonable behaviour on a regular NSPointerArray but not for a weakObjectPointerArray.
57 // As a workaround, we mutate it first. See: http://www.openradar.me/15396578
58 [self.engines addPointer:nil];
59 [self.engines compact];
60 if (self.engines.count <= 0) {
61 engine = [self makeEngine];
62 [engine runWithEntrypoint:entrypoint
63 libraryURI:libraryURI
64 initialRoute:initialRoute
65 entrypointArgs:entrypointArgs];
66 } else {
67 FlutterEngine* spawner = (__bridge FlutterEngine*)[self.engines pointerAtIndex:0];
68 engine = [spawner spawnWithEntrypoint:entrypoint
69 libraryURI:libraryURI
70 initialRoute:initialRoute
71 entrypointArgs:entrypointArgs];
72 }
73 [self.engines addPointer:(__bridge void*)engine];
74
75 return engine;
76 }
engine
id engine
Definition: FlutterTextInputPluginTest.mm:136
FlutterEngine
Definition: FlutterEngine.h:61
-[FlutterEngine spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:]
FlutterEngine * spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:(/*nullable */NSString *entrypoint,[libraryURI]/*nullable */NSString *libraryURI,[initialRoute]/*nullable */NSString *initialRoute,[entrypointArgs]/*nullable */NSArray< NSString * > *entrypointArgs)
-[FlutterEngine runWithEntrypoint:libraryURI:initialRoute:entrypointArgs:]
BOOL runWithEntrypoint:libraryURI:initialRoute:entrypointArgs:(nullable NSString *entrypoint,[libraryURI] nullable NSString *libraryURI,[initialRoute] nullable NSString *initialRoute,[entrypointArgs] nullable NSArray< NSString * > *entrypointArgs)

## ◆ NS_UNAVAILABLE

- (instancetype) NS_UNAVAILABLE |  |  |

The documentation for this class was generated from the following files:

- shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h
- shell/platform/darwin/ios/framework/Source/FlutterEngineGroup.mm