Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
FlutterEngineGroup Class Reference

#include <FlutterEngineGroup.h>

Inheritance diagram for FlutterEngineGroup:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithName:project:
 
(FlutterEngine *) - makeEngineWithEntrypoint:libraryURI:
 
(FlutterEngine *) - makeEngineWithEntrypoint:libraryURI:initialRoute:
 
(FlutterEngine *) - makeEngineWithOptions:
 
(void) - dealloc [implementation]
 
(FlutterEngine *) - makeEngine [implementation]
 
(void) - onEngineWillBeDealloced: [implementation]
 

Properties

NSString * name [implementation]
 
NSMutableArray< NSValue * > * engines [implementation]
 
FlutterDartProjectproject [implementation]
 

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

◆ dealloc

- (void) dealloc
implementation

Definition at line 23 of file FlutterEngineGroup.mm.

40 {
41 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
42 [center removeObserver:self];
43 [_name release];
44 [_engines release];
45 [_project release];
46 [super dealloc];
47}
static SkScalar center(float pos0, float pos1)

◆ initWithName:project:

- (instancetype) initWithName: (NSString*)  name
project: (nullable FlutterDartProject*)  NS_DESIGNATED_INITIALIZER 
Initial value:
{
int _enginesCreatedCount

Initialize a new FlutterEngineGroup.

Parameters
nameThe name that will present in the threads shared across the engines in this group.
projectThe FlutterDartProject that all FlutterEngines in this group will be executing.

Definition at line 23 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}
NSString * _name
const char * name
Definition fuchsia.cc:50
FlutterDartProject * project
FlutterDartProject * _project
init(device_serial, adb_binary)
Definition _adb_path.py:12

◆ makeEngine

- (FlutterEngine *) makeEngine
implementation

Definition at line 23 of file FlutterEngineGroup.mm.

95 {
96 NSString* engineName = [NSString stringWithFormat:@"%@.%d", self.name, ++_enginesCreatedCount];
97 FlutterEngine* result = [[FlutterEngine alloc] initWithName:engineName project:self.project];
98 return [result autorelease];
99}
GAsyncResult * result

◆ makeEngineWithEntrypoint:libraryURI:

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

Creates a running FlutterEngine that shares components with this group.

Parameters
entrypointThe 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.
libraryURIThe 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 23 of file FlutterEngineGroup.mm.

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

◆ 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
entrypointThe 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.
libraryURIThe 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.
initialRouteThe 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 23 of file FlutterEngineGroup.mm.

54 :(nullable NSString*)entrypoint
55 libraryURI:(nullable NSString*)libraryURI
56 initialRoute:(nullable NSString*)initialRoute {
58 options.entrypoint = entrypoint;
59 options.libraryURI = libraryURI;
60 options.initialRoute = initialRoute;
61 return [self makeEngineWithOptions:options];
62}
const char * options

◆ makeEngineWithOptions:

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

Creates a running FlutterEngine that shares components with this group.

Parameters
optionsOptions that control how a FlutterEngine should be created.
See also
FlutterEngineGroupOptions

Definition at line 23 of file FlutterEngineGroup.mm.

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

◆ NS_UNAVAILABLE

- (instancetype) NS_UNAVAILABLE

◆ onEngineWillBeDealloced:

- (void) onEngineWillBeDealloced: (NSNotification*)  notification
implementation

Definition at line 23 of file FlutterEngineGroup.mm.

101 :(NSNotification*)notification {
102 [_engines removeObject:[NSValue valueWithPointer:notification.object]];
103}

Property Documentation

◆ engines

- (NSMutableArray<NSValue*>*) engines
readwritenonatomicretainimplementation

Provided by category FlutterEngineGroup().

Definition at line 22 of file FlutterEngineGroup.mm.

◆ name

- (NSString*) name
readwritenonatomiccopyimplementation

Provided by category FlutterEngineGroup().

Definition at line 21 of file FlutterEngineGroup.mm.

◆ project

- (FlutterDartProject*) project
readwritenonatomicretainimplementation

Provided by category FlutterEngineGroup().

Definition at line 23 of file FlutterEngineGroup.mm.


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