| Flutter macOS Embedder |

Instance Methods | Protected Attributes | Properties | List of all members
FlutterEngine Class Reference

`#import <FlutterEngine.h>`

Inheritance diagram for FlutterEngine:

## Instance Methods
(nonnull instancetype) | - initWithName:project:
(nonnull instancetype) | - initWithName:project:allowHeadlessExecution:
(nonnull instancetype) | - NS_UNAVAILABLE
(BOOL) | - runWithEntrypoint:
(void) | - shutDownEngine
(nonnull FlutterThreadSynchronizer *) | - testThreadSynchronizer

## Protected Attributes
| __pad0__: NSObject <FlutterTextureRegistry
| FlutterPluginRegistry

## Properties
FlutterViewController * | viewController
id< FlutterBinaryMessenger > | binaryMessenger

## Detailed Description

Coordinates a single instance of execution of a Flutter engine.

A FlutterEngine can only be attached with one controller from the native code.

Definition at line 30 of file FlutterEngine.h.

## Method Documentation

## ◆ initWithName:project:

- (nonnull instancetype) initWithName: |  | (nonnull NSString *) | labelPrefix
project: |  | (nullable FlutterDartProject *) | project

Initializes an engine with the given project.

Parameters

  labelPrefix | Currently unused; in the future, may be used for labelling threads as with the iOS FlutterEngine.
  project | The project configuration. If nil, a default FlutterDartProject will be used.

## ◆ initWithName:project:allowHeadlessExecution:

- (nonnull instancetype) initWithName: |  | (nonnull NSString *) | labelPrefix
project: |  | (nullable FlutterDartProject *) | project
allowHeadlessExecution: |  | (BOOL) | NS_DESIGNATED_INITIALIZER

Initializes an engine that can run headlessly with the given project.

Parameters

  labelPrefix | Currently unused; in the future, may be used for labelling threads as with the iOS FlutterEngine.
  project | The project configuration. If nil, a default FlutterDartProject will be used.

## ◆ NS_UNAVAILABLE

- (nonnull instancetype) NS_UNAVAILABLE |  |  |

## ◆ runWithEntrypoint:

- (BOOL) runWithEntrypoint: |  | (nullable NSString *) | entrypoint |

Runs a Dart program on an Isolate from the main Dart library (i.e. the library that contains `main()`).

The first call to this method will create a new Isolate. Subsequent calls will return immediately.

Parameters

  entrypoint | The name of a top-level function from the same Dart library that contains the app's main() function. If this is nil, it 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.

Returns
  YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.

## ◆ shutDownEngine

- (void) shutDownEngine |  |  |

Shuts the Flutter engine if it is running. The FlutterEngine instance must always be shutdown before it may be collected. Not shutting down the FlutterEngine instance before releasing it will result in the leak of that engine instance.

Note: Called from dealloc. Should not use accessors or other methods.

Definition at line 1108 of file FlutterEngine.mm.

1108 {
1109 if (_engine == nullptr) {
1110 return;
1111 }
1112
1113 [_threadSynchronizer shutdown];
1114 _threadSynchronizer = nil;
1115
1116 FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
1117 if (result != kSuccess) {
1118 NSLog(@"Could not de-initialize the Flutter engine: error %d", result);
1119 }
1120
1121 // Balancing release for the retain in the task runner dispatch table.
1122 CFRelease((CFTypeRef)self);
1123
1124 result = _embedderAPI.Shutdown(_engine);
1125 if (result != kSuccess) {
1126 NSLog(@"Failed to shut down Flutter engine: error %d", result);
1127 }
1128 _engine = nullptr;
1129 }

References _threadSynchronizer.

Referenced by flutter::testing::FlutterEngineTest::ShutDownEngine(), flutter::testing::FlutterEngineTest::TearDown(), and flutter::testing::TEST_F().

## ◆ testThreadSynchronizer

- (nonnull FlutterThreadSynchronizer*) testThreadSynchronizer |  |  |

Provided by category FlutterEngine(Tests).

## Member Data Documentation

## ◆ __pad0__

- __pad0__
| protected

Definition at line 31 of file FlutterEngine.h.

## ◆ FlutterPluginRegistry

- FlutterPluginRegistry
| protected

Definition at line 31 of file FlutterEngine.h.

## Property Documentation

## ◆ binaryMessenger

- (id< FlutterBinaryMessenger >) binaryMessenger
| readnonatomicassign

The `FlutterBinaryMessenger` for communicating with this engine.

Definition at line 91 of file FlutterEngine.h.

Referenced by flutter::testing::TEST_F().

## ◆ viewController

- (FlutterViewController *) viewController
| readwritenonatomicweak

The `FlutterViewController` of this engine, if any.

This view is used by legacy APIs that assume a single view.

Setting this field from nil to a non-nil view controller also updates the view controller's engine and ID.

Setting this field from non-nil to nil will terminate the engine if allowHeadlessExecution is NO.

Setting this field from non-nil to a different non-nil FlutterViewController is prohibited and will throw an assertion error.

Definition at line 86 of file FlutterEngine.h.

Referenced by flutter::testing::TEST_F().

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

- shell/platform/darwin/macos/framework/Headers/FlutterEngine.h
- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm

_threadSynchronizer
FlutterThreadSynchronizer * _threadSynchronizer
Definition: FlutterEngine.mm:452