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, copy, 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  * Engines in a group share task runners, including the platform thread of the first engine
53  * created in the group. All `-makeEngine*` methods must therefore be called on the main thread.
54  * See `FlutterEngine` class documentation.
55  *
56  * @warning This class is a work-in-progress and may change.
57  * @see https://github.com/flutter/flutter/issues/72009
58  */
60 @interface FlutterEngineGroup : NSObject
61 - (instancetype)init NS_UNAVAILABLE;
62 
63 /**
64  * Initialize a new FlutterEngineGroup.
65  *
66  * @param name The name that will present in the threads shared across the
67  * engines in this group.
68  * @param project The `FlutterDartProject` that all FlutterEngines in this group
69  * will be executing.
70  */
71 - (instancetype)initWithName:(NSString*)name
72  project:(nullable FlutterDartProject*)project NS_DESIGNATED_INITIALIZER;
73 
74 /**
75  * Creates a running `FlutterEngine` that shares components with this group.
76  *
77  * This method must be called on the main thread.
78  *
79  * @param entrypoint The name of a top-level function from a Dart library. If this is
80  * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
81  * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
82  * method is not tree-shaken by the Dart compiler.
83  * @param libraryURI The URI of the Dart library which contains the entrypoint method. IF nil,
84  * this will default to the same library as the `main()` function in the Dart program.
85  *
86  * @see FlutterEngineGroup
87  */
88 - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
89  libraryURI:(nullable NSString*)libraryURI NS_SWIFT_UI_ACTOR;
90 
91 /**
92  * Creates a running `FlutterEngine` that shares components with this group.
93  *
94  * This method must be called on the main thread.
95  *
96  * @param entrypoint The name of a top-level function from a Dart library. If this is
97  * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
98  * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
99  * method is not tree-shaken by the Dart compiler.
100  * @param libraryURI The URI of the Dart library which contains the entrypoint method. IF nil,
101  * this will default to the same library as the `main()` function in the Dart program.
102  * @param initialRoute The name of the initial Flutter `Navigator` `Route` to load. If this is
103  * FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
104  *
105  * @see FlutterEngineGroup
106  */
107 - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
108  libraryURI:(nullable NSString*)libraryURI
109  initialRoute:(nullable NSString*)initialRoute NS_SWIFT_UI_ACTOR;
110 
111 /**
112  * Creates a running `FlutterEngine` that shares components with this group.
113  *
114  * This method must be called on the main thread.
115  *
116  * @param options Options that control how a FlutterEngine should be created.
117  *
118  * @see FlutterEngineGroupOptions
119  */
120 - (FlutterEngine*)makeEngineWithOptions:(nullable FlutterEngineGroupOptions*)options
121  NS_SWIFT_UI_ACTOR;
122 @end
123 
125 
126 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_HEADERS_FLUTTERENGINEGROUP_H_
#define NS_ASSUME_NONNULL_BEGIN
Definition: FlutterMacros.h:19
#define NS_ASSUME_NONNULL_END
Definition: FlutterMacros.h:20
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
instancetype init NS_UNAVAILABLE
NSArray< NSString * > * entrypointArgs