| 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

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

1320 {
1321 if (_engine == nullptr) {
1322 return;
1323 }
1324
1325 FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
1326 if (result != kSuccess) {
1327 NSLog(@"Could not de-initialize the Flutter engine: error %d", result);
1328 }
1329
1330 result = _embedderAPI.Shutdown(_engine);
1331 if (result != kSuccess) {
1332 NSLog(@"Failed to shut down Flutter engine: error %d", result);
1333 }
1334 _engine = nullptr;
1335 }

References kMainThreadPriority.

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

## Member Data Documentation

## ◆ __pad0__

- __pad0__
| protected

Definition at line 30 of file FlutterEngine.h.

## ◆ FlutterPluginRegistry

- FlutterPluginRegistry
| protected

Definition at line 32 of file FlutterEngine.h.

## Property Documentation

## ◆ binaryMessenger

- (id< FlutterBinaryMessenger >) binaryMessenger
| read nonatomic assign

The `FlutterBinaryMessenger` for communicating with this engine.

Definition at line 92 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 87 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