Flutter Engine
FlutterEngine.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_FLUTTERENGINE_H_
6 #define FLUTTER_FLUTTERENGINE_H_
7 
8 #import <Foundation/Foundation.h>
9 
11 #import "FlutterDartProject.h"
12 #import "FlutterMacros.h"
14 #import "FlutterTexture.h"
15 
16 // TODO: Merge this file with the iOS FlutterEngine.h.
17 
19 
20 /**
21  * Coordinates a single instance of execution of a Flutter engine.
22  */
24 @interface FlutterEngine : NSObject <FlutterTextureRegistry, FlutterPluginRegistry>
25 
26 /**
27  * Initializes an engine with the given viewController.
28  *
29  * @param labelPrefix Currently unused; in the future, may be used for labelling threads
30  * as with the iOS FlutterEngine.
31  * @param project The project configuration. If nil, a default FlutterDartProject will be used.
32  */
33 - (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
34  project:(nullable FlutterDartProject*)project;
35 
36 /**
37  * Initializes an engine with the given viewController.
38  *
39  * @param labelPrefix Currently unused; in the future, may be used for labelling threads
40  * as with the iOS FlutterEngine.
41  * @param project The project configuration. If nil, a default FlutterDartProject will be used.
42  */
43 - (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
44  project:(nullable FlutterDartProject*)project
45  allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;
46 
47 - (nonnull instancetype)init NS_UNAVAILABLE;
48 
49 /**
50  * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
51  * contains `main()`).
52  *
53  * The first call to this method will create a new Isolate. Subsequent calls will return
54  * immediately.
55  *
56  * @param entrypoint The name of a top-level function from the same Dart
57  * library that contains the app's main() function. If this is nil, it will
58  * default to `main()`. If it is not the app's main() function, that function
59  * must be decorated with `@pragma(vm:entry-point)` to ensure the method is not
60  * tree-shaken by the Dart compiler.
61  * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
62  */
63 - (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;
64 
65 /**
66  * The `FlutterViewController` associated with this engine, if any.
67  */
68 @property(nonatomic, nullable, weak) FlutterViewController* viewController;
69 
70 /**
71  * The `FlutterBinaryMessenger` for communicating with this engine.
72  */
73 @property(nonatomic, nonnull, readonly) id<FlutterBinaryMessenger> binaryMessenger;
74 
75 /**
76  * Shuts the Flutter engine if it is running. The FlutterEngine instance must always be shutdown
77  * before it may be collected. Not shutting down the FlutterEngine instance before releasing it will
78  * result in the leak of that engine instance.
79  */
80 - (void)shutDownEngine;
81 
82 @end
83 
84 #endif // FLUTTER_FLUTTERENGINE_H_
NSObject< FlutterBinaryMessenger > * binaryMessenger
instancetype NS_UNAVAILABLE()
instancetype init()
#define FLUTTER_EXPORT
FlutterViewController * viewController