| 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

Initial value:
{
int _enginesCreatedCount

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 30 of file FlutterEngineGroup.mm.

30 :(NSString*)name project:(nullable FlutterDartProject*)project {
31 self = [super init];
32 if (self) {
33 _name = [name copy];
34 _engines = [[NSMutableArray<NSValue*> alloc] init];
35 _project = [project retain];
36 }
37 return self;
38 }

References _name.

## ◆ 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 47 of file FlutterEngineGroup.mm.

47 :(nullable NSString*)entrypoint
48 libraryURI:(nullable NSString*)libraryURI {
49 return [self makeEngineWithEntrypoint:entrypoint libraryURI:libraryURI initialRoute:nil];
50 }

References makeEngineWithEntrypoint:libraryURI:initialRoute:.

## ◆ 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 52 of file FlutterEngineGroup.mm.

52 :(nullable NSString*)entrypoint
53 libraryURI:(nullable NSString*)libraryURI
54 initialRoute:(nullable NSString*)initialRoute {
55 FlutterEngineGroupOptions* options = [[[FlutterEngineGroupOptions alloc] init] autorelease];
56 options.entrypoint = entrypoint;
57 options.libraryURI = libraryURI;
58 options.initialRoute = initialRoute;
59 return [self makeEngineWithOptions:options];
60 }

References FlutterEngineGroupOptions::entrypoint, FlutterEngineGroupOptions::initialRoute, FlutterEngineGroupOptions::libraryURI, and makeEngineWithOptions:.

Referenced by makeEngineWithEntrypoint:libraryURI:.

## ◆ 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 62 of file FlutterEngineGroup.mm.

62 :(nullable FlutterEngineGroupOptions*)options {
63 NSString* entrypoint = options.entrypoint;
64 NSString* libraryURI = options.libraryURI;
65 NSString* initialRoute = options.initialRoute;
66 NSArray<NSString*>* entrypointArgs = options.entrypointArgs;
67
68 FlutterEngine* engine;
69 if (self.engines.count <= 0) {
70 engine = [self makeEngine];
71 [engine runWithEntrypoint:entrypoint
72 libraryURI:libraryURI
73 initialRoute:initialRoute
74 entrypointArgs:entrypointArgs];
75 } else {
76 FlutterEngine* spawner = (FlutterEngine*)[self.engines[0] pointerValue];
77 engine = [spawner spawnWithEntrypoint:entrypoint
78 libraryURI:libraryURI
79 initialRoute:initialRoute
80 entrypointArgs:entrypointArgs];
81 }
82 [_engines addObject:[NSValue valueWithPointer:engine]];
83
84 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
85 [center addObserver:self
86 selector:@selector(onEngineWillBeDealloced:)
87 name:kFlutterEngineWillDealloc
88 object:engine];
89
90 return engine;
91 }

References engine, FlutterEngineGroupOptions::entrypoint, FlutterEngineGroupOptions::entrypointArgs, FlutterEngineGroupOptions::initialRoute, FlutterEngineGroupOptions::libraryURI, FlutterEngine::runWithEntrypoint:libraryURI:initialRoute:entrypointArgs:, and FlutterEngine::spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:.

Referenced by makeEngineWithEntrypoint:libraryURI:initialRoute:.

## ◆ 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

FlutterEngine
Definition: FlutterEngine.h:61
FlutterEngineGroupOptions::libraryURI
NSString * libraryURI
Definition: FlutterEngineGroup.h:30
FlutterEngineGroupOptions::entrypoint
NSString * entrypoint
Definition: FlutterEngineGroup.h:24
FlutterEngineGroupOptions::initialRoute
NSString * initialRoute
Definition: FlutterEngineGroup.h:36
FlutterEngineGroupOptions
Definition: FlutterEngineGroup.h:16
engine
id engine
Definition: FlutterTextInputPluginTest.mm:89
_name
NSString * _name
Definition: FlutterChannels.mm:68
FlutterDartProject
Definition: FlutterDartProject.mm:262
-[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)