| Flutter macOS Embedder |

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_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERENGINE_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERENGINE_H_
7
8 #import <Foundation/Foundation.h>
9
10 #include <stdint.h>
11
12 #import "FlutterAppLifecycleDelegate.h"
13 #import "FlutterBinaryMessenger.h"
14 #import "FlutterDartProject.h"
15 #import "FlutterHourFormat.h"
16 #import "FlutterMacros.h"
17 #import "FlutterPluginRegistrarMacOS.h"
18 #import "FlutterTexture.h"
19
20 // TODO(stuartmorgan): Merge this file with the iOS FlutterEngine.h.
21
22 @class FlutterViewController;
23
24 /**
25 * Coordinates a single instance of execution of a Flutter engine.
26 *
27 * A FlutterEngine can only be attached with one controller from the native
28 * code.
29 */
30 FLUTTER_DARWIN_EXPORT
31 @interface FlutterEngine
32 : NSObject <FlutterTextureRegistry, FlutterPluginRegistry, FlutterAppLifecycleDelegate>
33
34 /**
35 * Initializes an engine with the given project.
36 *
37 * @param labelPrefix Currently unused; in the future, may be used for labelling threads
38 * as with the iOS FlutterEngine.
39 * @param project The project configuration. If nil, a default FlutterDartProject will be used.
40 */
41 - (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
42 project:(nullable FlutterDartProject*)project;
43
44 /**
45 * Initializes an engine that can run headlessly with the given project.
46 *
47 * @param labelPrefix Currently unused; in the future, may be used for labelling threads
48 * as with the iOS FlutterEngine.
49 * @param project The project configuration. If nil, a default FlutterDartProject will be used.
50 */
51 - (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
52 project:(nullable FlutterDartProject*)project
53 allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;
54
55 - (nonnull instancetype)init NS_UNAVAILABLE;
56
57 /**
58 * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
59 * contains `main()`).
60 *
61 * The first call to this method will create a new Isolate. Subsequent calls will return
62 * immediately.
63 *
64 * @param entrypoint The name of a top-level function from the same Dart
65 * library that contains the app's main() function. If this is nil, it will
66 * default to `main()`. If it is not the app's main() function, that function
67 * must be decorated with `@pragma(vm:entry-point)` to ensure the method is not
68 * tree-shaken by the Dart compiler.
69 * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
70 */
71 - (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;
72
73 /**
74 * The `FlutterViewController` of this engine, if any.
75 *
76 * This view is used by legacy APIs that assume a single view.
77 *
78 * Setting this field from nil to a non-nil view controller also updates
79 * the view controller's engine and ID.
80 *
81 * Setting this field from non-nil to nil will terminate the engine if
82 * allowHeadlessExecution is NO.
83 *
84 * Setting this field from non-nil to a different non-nil FlutterViewController
85 * is prohibited and will throw an assertion error.
86 */
87 @property(nonatomic, nullable, weak) FlutterViewController* viewController;
88
89 /**
90 * The `FlutterBinaryMessenger` for communicating with this engine.
91 */
92 @property(nonatomic, nonnull, readonly) id<FlutterBinaryMessenger> binaryMessenger;
93
94 /**
95 * Shuts the Flutter engine if it is running. The FlutterEngine instance must always be shutdown
96 * before it may be collected. Not shutting down the FlutterEngine instance before releasing it will
97 * result in the leak of that engine instance.
98 */
99 - (void)shutDownEngine;
100
101 @end
102
103 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERENGINE_H_
FlutterAppLifecycleDelegate.h
FlutterBinaryMessenger.h
FlutterDartProject.h
FlutterHourFormat.h
FlutterMacros.h
FLUTTER_DARWIN_EXPORT
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
FlutterPluginRegistrarMacOS.h
FlutterTexture.h
FlutterDartProject
Definition: FlutterDartProject.mm:24
FlutterEngine
Definition: FlutterEngine.h:32
FlutterEngine::binaryMessenger
id< FlutterBinaryMessenger > binaryMessenger
Definition: FlutterEngine.h:92
-[FlutterEngine NS_UNAVAILABLE]
nonnull instancetype NS_UNAVAILABLE()
-[FlutterEngine shutDownEngine]
void shutDownEngine()
Definition: FlutterEngine.mm:1320
FlutterEngine::viewController
FlutterViewController * viewController
Definition: FlutterEngine.h:87
FlutterViewController
Definition: FlutterViewController.h:73