Flutter iOS Embedder
FlutterEngineGroup.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_HEADERS_FLUTTERENGINEGROUP_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_HEADERS_FLUTTERENGINEGROUP_H_
7 
8 #import <Foundation/Foundation.h>
9 
10 #import "FlutterEngine.h"
11 
13 
14 /** Options that control how a FlutterEngine should be created. */
16 @interface FlutterEngineGroupOptions : NSObject
17 
18 /**
19  * The name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint
20  * (or nil); this will default to `main()`. If it is not the app's main() function, that function
21  * must be decorated with `@pragma(vm:entry-point)` to ensure themethod is not tree-shaken by the
22  * Dart compiler.
23  */
24 @property(nonatomic, copy, nullable) NSString* entrypoint;
25 
26 /**
27  * The URI of the Dart library which contains the entrypoint method. If nil, this will default to
28  * the same library as the `main()` function in the Dart program.
29  */
30 @property(nonatomic, copy, nullable) NSString* libraryURI;
31 
32 /**
33  * The name of the initial Flutter `Navigator` `Route` to load. If this is
34  * FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
35  */
36 @property(nonatomic, copy, nullable) NSString* initialRoute;
37 
38 /**
39  * Arguments passed as a list of string to Dart's entrypoint function.
40  */
41 @property(nonatomic, retain, nullable) NSArray<NSString*>* entrypointArgs;
42 @end
43 
44 /**
45  * Represents a collection of FlutterEngines who share resources which allows
46  * them to be created with less time const and occupy less memory than just
47  * creating multiple FlutterEngines.
48  *
49  * Deleting a FlutterEngineGroup doesn't invalidate existing FlutterEngines, but
50  * it eliminates the possibility to create more FlutterEngines in that group.
51  *
52  * @warning This class is a work-in-progress and may change.
53  * @see https://github.com/flutter/flutter/issues/72009
54  */
56 @interface FlutterEngineGroup : NSObject
57 - (instancetype)init NS_UNAVAILABLE;
58 
59 /**
60  * Initialize a new FlutterEngineGroup.
61  *
62  * @param name The name that will present in the threads shared across the
63  * engines in this group.
64  * @param project The `FlutterDartProject` that all FlutterEngines in this group
65  * will be executing.
66  */
67 - (instancetype)initWithName:(NSString*)name
68  project:(nullable FlutterDartProject*)project NS_DESIGNATED_INITIALIZER;
69 
70 /**
71  * Creates a running `FlutterEngine` that shares components with this group.
72  *
73  * @param entrypoint The name of a top-level function from a Dart library. If this is
74  * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
75  * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
76  * method is not tree-shaken by the Dart compiler.
77  * @param libraryURI The URI of the Dart library which contains the entrypoint method. IF nil,
78  * this will default to the same library as the `main()` function in the Dart program.
79  *
80  * @see FlutterEngineGroup
81  */
82 - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
83  libraryURI:(nullable NSString*)libraryURI;
84 
85 /**
86  * Creates a running `FlutterEngine` that shares components with this group.
87  *
88  * @param entrypoint The name of a top-level function from a Dart library. If this is
89  * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
90  * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
91  * method is not tree-shaken by the Dart compiler.
92  * @param libraryURI The URI of the Dart library which contains the entrypoint method. IF nil,
93  * this will default to the same library as the `main()` function in the Dart program.
94  * @param initialRoute The name of the initial Flutter `Navigator` `Route` to load. If this is
95  * FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
96  *
97  * @see FlutterEngineGroup
98  */
99 - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
100  libraryURI:(nullable NSString*)libraryURI
101  initialRoute:(nullable NSString*)initialRoute;
102 
103 /**
104  * Creates a running `FlutterEngine` that shares components with this group.
105  *
106  * @param options Options that control how a FlutterEngine should be created.
107  *
108  * @see FlutterEngineGroupOptions
109  */
110 - (FlutterEngine*)makeEngineWithOptions:(nullable FlutterEngineGroupOptions*)options;
111 @end
112 
114 
115 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_HEADERS_FLUTTERENGINEGROUP_H_
FlutterEngine
Definition: FlutterEngine.h:61
FlutterEngine.h
FlutterEngineGroupOptions::libraryURI
NSString * libraryURI
Definition: FlutterEngineGroup.h:30
NS_ASSUME_NONNULL_END
#define NS_ASSUME_NONNULL_END
Definition: FlutterMacros.h:20
NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_BEGIN
Definition: FlutterMacros.h:19
FlutterEngineGroupOptions::entrypoint
NSString * entrypoint
Definition: FlutterEngineGroup.h:24
FlutterEngineGroupOptions::initialRoute
NSString * initialRoute
Definition: FlutterEngineGroup.h:36
FlutterEngineGroupOptions
Definition: FlutterEngineGroup.h:16
NS_UNAVAILABLE
instancetype init NS_UNAVAILABLE
Definition: FlutterTextInputPlugin.h:169
FLUTTER_DARWIN_EXPORT
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
FlutterEngineGroupOptions::entrypointArgs
NSArray< NSString * > * entrypointArgs
Definition: FlutterEngineGroup.h:41
FlutterDartProject
Definition: FlutterDartProject.mm:262
FlutterEngineGroup
Definition: FlutterEngineGroup.h:56