| Flutter macOS Embedder |

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

`#import <FlutterEngine.h>`

## 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 1035 of file FlutterEngine.mm.

1035 {
1036 if (_engine == nullptr) {
1037 return;
1038 }
1039
1040 [_threadSynchronizer shutdown];
1041 _threadSynchronizer = nil;
1042
1043 FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
1044 if (result != kSuccess) {
1045 NSLog(@"Could not de-initialize the Flutter engine: error %d", result);
1046 }
1047
1048 // Balancing release for the retain in the task runner dispatch table.
1049 CFRelease((CFTypeRef)self);
1050
1051 result = _embedderAPI.Shutdown(_engine);
1052 if (result != kSuccess) {
1053 NSLog(@"Failed to shut down Flutter engine: error %d", result);
1054 }
1055 _engine = nullptr;
1056 }

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
| read nonatomic assign

The `FlutterBinaryMessenger` for communicating with this engine.

Definition at line 91 of file FlutterEngine.h.

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

## ◆ viewController

- (FlutterViewController *) viewController
| read write nonatomic weak

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:449