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

#import <FlutterEngine.h>

Inheritance diagram for FlutterEngine:
<FlutterMouseCursorPluginDelegate> <FlutterViewEngineDelegate> <FlutterTextureRegistry> <FlutterBinaryMessenger> <FlutterTextInputDelegate> <FlutterUndoManagerDelegate> <FlutterIndirectScribbleDelegate> <FlutterPluginRegistry> FlutterEnginePartialMock FlutterEngineSpy FlutterHeadlessDartRunner MockableFlutterEngine

Instance Methods

(instancetype) - init
 
(instancetype) - initWithName:
 
(instancetype) - initWithName:project:
 
(instancetype) - initWithName:project:allowHeadlessExecution:
 
(instancetype) - initWithName:project:allowHeadlessExecution:restorationEnabled:
 
(BOOL- run
 
(BOOL- runWithEntrypoint:
 
(BOOL- runWithEntrypoint:initialRoute:
 
(BOOL- runWithEntrypoint:libraryURI:
 
(BOOL- runWithEntrypoint:libraryURI:initialRoute:
 
(BOOL- runWithEntrypoint:libraryURI:initialRoute:entrypointArgs:
 
(void) - destroyContext
 
(void) - ensureSemanticsEnabled
 
(NSURL *observatoryUrl- FLUTTER_DEPRECATED
 
(nonnull instancetype) - initWithName:project:
 
(nonnull instancetype) - initWithName:project:allowHeadlessExecution:
 
(nonnull instancetype) - NS_UNAVAILABLE
 
(BOOL- runWithEntrypoint:
 
(void) - shutDownEngine
 
(instancetype) - initWithName:project: [implementation]
 
(instancetype) - initWithName:project:allowHeadlessExecution: [implementation]
 
(instancetype) - initWithName:project:allowHeadlessExecution:restorationEnabled: [implementation]
 
(void) - setUpSceneLifecycleNotifications: [implementation]
 
(void) - setUpApplicationLifecycleNotifications: [implementation]
 
(void) - recreatePlatformViewController [implementation]
 
(flutter::IOSRenderingAPI- platformViewsRenderingAPI [implementation]
 
(void) - dealloc [implementation]
 
(flutter::Shell &) - shell [implementation]
 
(fml::WeakNSObject< FlutterEngine >) - getWeakNSObject [implementation]
 
(void) - updateViewportMetrics: [implementation]
 
(void) - dispatchPointerDataPacket: [implementation]
 
(fml::WeakPtr< flutter::PlatformView >) - platformView [implementation]
 
(flutter::PlatformViewIOS *) - iosPlatformView [implementation]
 
(fml::RefPtr< fml::TaskRunner >) - platformTaskRunner [implementation]
 
(fml::RefPtr< fml::TaskRunner >) - uiTaskRunner [implementation]
 
(fml::RefPtr< fml::TaskRunner >) - rasterTaskRunner [implementation]
 
(void) - sendKeyEvent:callback:userData: [implementation]
 
(void) - setViewController: [implementation]
 
(void) - attachView [implementation]
 
(void) - setFlutterViewControllerWillDeallocObserver: [implementation]
 
(void) - notifyViewControllerDeallocated [implementation]
 
(FlutterPlatformPlugin *) - platformPlugin [implementation]
 
(std::shared_ptr< flutter::FlutterPlatformViewsController > &) - platformViewsController [implementation]
 
(FlutterTextInputPlugin *) - textInputPlugin [implementation]
 
(FlutterUndoManagerPlugin *) - undoManagerPlugin [implementation]
 
(FlutterRestorationPlugin *) - restorationPlugin [implementation]
 
(FlutterMethodChannel *) - undoManagerChannel [implementation]
 
(FlutterMethodChannel *) - scribbleChannel [implementation]
 
(FlutterMethodChannel *) - spellCheckChannel [implementation]
 
(NSURL *) - observatoryUrl [implementation]
 
(void) - resetChannels [implementation]
 
(void) - startProfiler [implementation]
 
(void) - setUpChannels [implementation]
 
(void) - maybeSetupPlatformViewChannels [implementation]
 
(flutter::Rasterizer::Screenshot- screenshot:base64Encode: [implementation]
 
(void) - launchEngine:libraryURI:entrypointArgs: [implementation]
 
(void) - setUpShell:withVMServicePublication: [implementation]
 
(BOOL- createShell:libraryURI:initialRoute: [implementation]
 
(void) - updateDisplays [implementation]
 
(BOOL- runWithEntrypoint:libraryURI: [implementation]
 
(BOOL- runWithEntrypoint: [implementation]
 
(BOOL- runWithEntrypoint:initialRoute: [implementation]
 
(BOOL- runWithEntrypoint:libraryURI:initialRoute: [implementation]
 
(BOOL- runWithEntrypoint:libraryURI:initialRoute:entrypointArgs: [implementation]
 
(void) - notifyLowMemory [implementation]
 
(void) - flutterTextInputView:updateEditingClient:withState: [implementation]
 
(void) - flutterTextInputView:updateEditingClient:withState:withTag: [implementation]
 
(void) - flutterTextInputView:updateEditingClient:withDelta: [implementation]
 
(void) - flutterTextInputView:updateFloatingCursor:withClient:withPosition: [implementation]
 
(void) - flutterTextInputView:performAction:withClient: [implementation]
 
(void) - flutterTextInputView:showAutocorrectionPromptRectForStart:end:withClient: [implementation]
 
(void) - flutterTextInputView:willDismissEditMenuWithTextInputClient: [implementation]
 
(void) - flutterTextInputView:showToolbar: [implementation]
 
(void) - flutterTextInputPlugin:focusElement:atPoint:result: [implementation]
 
(void) - flutterTextInputPlugin:requestElementsInRect:result: [implementation]
 
(void) - flutterTextInputViewScribbleInteractionBegan: [implementation]
 
(void) - flutterTextInputViewScribbleInteractionFinished: [implementation]
 
(void) - flutterTextInputView:insertTextPlaceholderWithSize:withClient: [implementation]
 
(void) - flutterTextInputView:removeTextPlaceholder: [implementation]
 
(void) - flutterTextInputView:didResignFirstResponderWithTextInputClient: [implementation]
 
(void) - handleUndoWithDirection: [implementation]
 
(UIView< UITextInput > *) - activeTextInputView [implementation]
 
(NSUndoManager *) - undoManager [implementation]
 
(flutter::Rasterizer::Screenshot- takeScreenshot:asBase64Encoded: [implementation]
 
(void) - flutterViewAccessibilityDidCall [implementation]
 
(void) - setBinaryMessenger: [implementation]
 
(void) - sendOnChannel:message: [implementation]
 
(void) - sendOnChannel:message:binaryReply: [implementation]
 
(NSObject< FlutterTaskQueue > *) - makeBackgroundTaskQueue [implementation]
 TODO(gaaclarke): Remove optional when macos supports Background Platform Channels. More...
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler: [implementation]
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler:taskQueue: [implementation]
 
(void) - cleanUpConnection: [implementation]
 
(int64_t) - registerTexture: [implementation]
 
(void) - unregisterTexture: [implementation]
 
(void) - textureFrameAvailable: [implementation]
 
(NSString *) - lookupKeyForAsset: [implementation]
 
(NSString *) - lookupKeyForAsset:fromPackage: [implementation]
 
(id< FlutterPluginRegistry >) - pluginRegistry [implementation]
 
(NSObject< FlutterPluginRegistrar > *) - registrarForPlugin: [implementation]
 
(BOOL- hasPlugin: [implementation]
 
(NSObject *) - valuePublishedByPlugin: [implementation]
 
(void) - applicationWillEnterForeground: [implementation]
 
(void) - applicationDidEnterBackground: [implementation]
 
(void) - flutterWillEnterForeground: [implementation]
 
(void) - flutterDidEnterBackground: [implementation]
 
(void) - onMemoryWarning: [implementation]
 
(void) - setIsGpuDisabled: [implementation]
 
(void) - onLocaleUpdated: [implementation]
 
(void) - waitForFirstFrame:callback: [implementation]
 
(FlutterEngine *) - spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs: [implementation]
 
(const flutter::ThreadHost &) - threadHost [implementation]
 
(FlutterDartProject *) - project [implementation]
 
(BOOL- isUsingImpeller [implementation]
 
(void) - loadAOTData: [implementation]
 
(void) - registerViewController:forIdentifier: [implementation]
 
(void) - viewControllerViewDidLoad: [implementation]
 
(void) - deregisterViewControllerForIdentifier: [implementation]
 
(void) - shutDownIfNeeded [implementation]
 
(FlutterViewController *) - viewControllerForIdentifier: [implementation]
 
(FlutterCompositor *) - createFlutterCompositor [implementation]
 
(void) - addViewController: [implementation]
 
(void) - removeViewController: [implementation]
 
(BOOL- running [implementation]
 
(void) - updateDisplayConfig: [implementation]
 
(NSArray< NSScreen * > *) - screens [implementation]
 
(void) - updateDisplayConfig [implementation]
 
(void) - onSettingsChanged: [implementation]
 
(void) - sendInitialSettings [implementation]
 
(FlutterEngineProcTable &) - embedderAPI [implementation]
 
(nonnull NSString *) - executableName [implementation]
 
(void) - updateWindowMetricsForViewController: [implementation]
 
(void) - sendPointerEvent: [implementation]
 
(void) - sendKeyEvent:callback:userData: [implementation]
 
(void) - setSemanticsEnabled: [implementation]
 
(void) - dispatchSemanticsAction:toTarget:withData: [implementation]
 
(FlutterPlatformViewController *) - platformViewController [implementation]
 
(void) - sendUserLocales [implementation]
 
(void) - engineCallbackOnPlatformMessage: [implementation]
 
(void) - engineCallbackOnPreEngineRestart [implementation]
 
(void) - onVSync: [implementation]
 
(void) - setUpPlatformViewChannel [implementation]
 
(void) - setUpAccessibilityChannel [implementation]
 
(void) - setUpNotificationCenterListeners [implementation]
 
(void) - addInternalPlugins [implementation]
 
(void) - didUpdateMouseCursor: [implementation]
 
(void) - applicationWillTerminate: [implementation]
 
(void) - windowDidChangeScreen: [implementation]
 
(void) - onAccessibilityStatusChanged: [implementation]
 
(void) - handleAccessibilityEvent: [implementation]
 
(void) - announceAccessibilityMessage:withPriority: [implementation]
 
(void) - handleMethodCall:result: [implementation]
 
(void) - playSystemSound: [implementation]
 
(NSDictionary *) - getClipboardData: [implementation]
 
(void) - setClipboardData: [implementation]
 
(BOOL- clipboardHasStrings [implementation]
 
(std::vector< std::string >) - switches [implementation]
 
(FlutterThreadSynchronizer *) - testThreadSynchronizer [implementation]
 
(void) - setApplicationState: [implementation]
 
(void) - handleWillBecomeActive: [implementation]
 
(void) - handleWillResignActive: [implementation]
 
(void) - handleDidChangeOcclusionState: [implementation]
 
(void) - sendOnChannel:message: [implementation]
 
(void) - sendOnChannel:message:binaryReply: [implementation]
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler: [implementation]
 
(int64_t) - registerTexture: [implementation]
 
(BOOL- registerTextureWithID: [implementation]
 
(BOOL- markTextureFrameAvailable: [implementation]
 
(BOOL- unregisterTextureWithID: [implementation]
 
(void) - runTaskOnEmbedder: [implementation]
 
(void) - postMainThreadTask:targetTimeInNanoseconds: [implementation]
 
(flutter::FlutterCompositor *) - macOSCompositor [implementation]
 
(instancetype) - initWithScenario:withCompletion:
 
(void) - sceneWillEnterForeground:
 
(void) - sceneDidEnterBackground:
 
- Instance Methods inherited from <FlutterPluginRegistry>
(nullable NSObject< FlutterPluginRegistrar > *) - registrarForPlugin:
 
(BOOL- hasPlugin:
 
(nullable NSObject *) - valuePublishedByPlugin:
 
(nonnull id< FlutterPluginRegistrar >) - registrarForPlugin:
 
(nullable NSObject *) - valuePublishedByPlugin:
 
(void) - flutterTextInputPlugin:focusElement:atPoint:result:
 
(void) - flutterTextInputPlugin:requestElementsInRect:result:
 
(void) - handleUndoWithDirection:
 
(void) - flutterTextInputView:updateEditingClient:withState:
 
(void) - flutterTextInputView:updateEditingClient:withState:withTag:
 
(void) - flutterTextInputView:updateEditingClient:withDelta:
 
(void) - flutterTextInputView:performAction:withClient:
 
(void) - flutterTextInputView:updateFloatingCursor:withClient:withPosition:
 
(void) - flutterTextInputView:showAutocorrectionPromptRectForStart:end:withClient:
 
(void) - flutterTextInputView:showToolbar:
 
(void) - flutterTextInputViewScribbleInteractionBegan:
 
(void) - flutterTextInputViewScribbleInteractionFinished:
 
(void) - flutterTextInputView:insertTextPlaceholderWithSize:withClient:
 
(void) - flutterTextInputView:removeTextPlaceholder:
 
(void) - flutterTextInputView:didResignFirstResponderWithTextInputClient:
 
(void) - flutterTextInputView:willDismissEditMenuWithTextInputClient:
 
- Instance Methods inherited from <FlutterBinaryMessenger>
(NSObject< FlutterTaskQueue > *) - makeBackgroundTaskQueue
 TODO(gaaclarke): Remove optional when macos supports Background Platform Channels. More...
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler:taskQueue:
 
(void) - sendOnChannel:message:
 
(void) - sendOnChannel:message:binaryReply:
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler:
 
(void) - cleanUpConnection:
 
(int64_t) - registerTexture:
 
(void) - textureFrameAvailable:
 
(void) - unregisterTexture:
 
(flutter::Rasterizer::Screenshot- takeScreenshot:asBase64Encoded:
 
(std::shared_ptr< flutter::FlutterPlatformViewsController > &) - platformViewsController
 
(void) - flutterViewAccessibilityDidCall
 
- Instance Methods inherited from <FlutterMouseCursorPluginDelegate>
(void) - didUpdateMouseCursor:
 

Class Methods

(BOOL+ isProfilerEnabled [implementation]
 
(NSString *) + generateThreadLabel: [implementation]
 
(flutter::ThreadHost+ makeThreadHost: [implementation]
 
(static void) + SetEntryPoint [implementation]
 
(static void) + SetThreadPriority [implementation]
 

Protected Attributes

 __pad0__: NSObject <FlutterTextureRegistry
 
 FlutterPluginRegistry
 

Properties

FlutterViewControllerviewController
 
FlutterMethodChannellocalizationChannel
 
FlutterMethodChannelnavigationChannel
 
FlutterMethodChannelrestorationChannel
 
FlutterMethodChannelplatformChannel
 
FlutterMethodChanneltextInputChannel
 
FlutterBasicMessageChannellifecycleChannel
 
FlutterBasicMessageChannelsystemChannel
 
FlutterBasicMessageChannelsettingsChannel
 
FlutterBasicMessageChannelkeyEventChannel
 
NSURL * vmServiceUrl
 
NSObject< FlutterBinaryMessenger > * binaryMessenger
 
NSObject< FlutterTextureRegistry > * textureRegistry
 
NSString * isolateId
 
BOOL isGpuDisabled
 
id< FlutterBinaryMessengerbinaryMessenger
 
NSMutableDictionary * pluginPublications [implementation]
 
NSMutableDictionary< NSString *, FlutterEngineRegistrar * > * registrars [implementation]
 
NSString * initialRoute [implementation]
 
id< NSObject > flutterViewControllerWillDeallocObserver [implementation]
 
BOOL enableEmbedderAPI [implementation]
 
NSMutableArray< NSNumber * > * isResponseValid [implementation]
 
NSPointerArray * pluginAppDelegates [implementation]
 
NSMutableDictionary< NSString *, FlutterEngineRegistrar * > * pluginRegistrars [implementation]
 
FlutterRendererrenderer [implementation]
 
BOOL semanticsEnabled [implementation]
 
FlutterPasteboardpasteboard [implementation]
 
FlutterEngineTerminationHandlerterminationHandler [implementation]
 
- Properties inherited from <FlutterUndoManagerDelegate>
NSUndoManager * undoManager
 
UIView< UITextInput > * activeTextInputView
 
- Properties inherited from <FlutterViewEngineDelegate>
BOOL isUsingImpeller
 

Detailed Description

The FlutterEngine class coordinates a single instance of execution for a FlutterDartProject. It may have zero or one FlutterViewController at a time, which can be specified via -setViewController:. FlutterViewController's initWithEngine initializer will automatically call -setViewController: for itself.

A FlutterEngine can be created independently of a FlutterViewController for headless execution. It can also persist across the lifespan of multiple FlutterViewController instances to maintain state and/or asynchronous tasks (such as downloading a large file).

A FlutterEngine can also be used to prewarm the Dart execution environment and reduce the latency of showing the Flutter screen when a FlutterViewController is created and presented. See http://flutter.dev/docs/development/add-to-app/performance for more details on loading performance.

Alternatively, you can simply create a new FlutterViewController with only a FlutterDartProject. That FlutterViewController will internally manage its own instance of a FlutterEngine, but will not guarantee survival of the engine beyond the life of the ViewController.

A newly initialized FlutterEngine will not actually run a Dart Isolate until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI is invoked. One of these methods must be invoked before calling -setViewController:.

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 61 of file FlutterEngine.h.

Method Documentation

◆ activeTextInputView

- (UIView< UITextInput > *) activeTextInputView
implementation

Used to notify the active view when undo manager state (can redo/can undo) changes, in order to force keyboards to update undo/redo buttons.

Reimplemented from <FlutterUndoManagerDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1201 {
1202 return [[self textInputPlugin] textInputView];
1203}

◆ addInternalPlugins

- (void) addInternalPlugins
implementation

Definition at line 484 of file FlutterEngine.mm.

1196 {
1197 __weak FlutterEngine* weakSelf = self;
1198 [FlutterMouseCursorPlugin registerWithRegistrar:[self registrarForPlugin:@"mousecursor"]
1199 delegate:self];
1200 [FlutterMenuPlugin registerWithRegistrar:[self registrarForPlugin:@"menu"]];
1202 [FlutterBasicMessageChannel messageChannelWithName:kFlutterSettingsChannel
1203 binaryMessenger:self.binaryMessenger
1206 [FlutterMethodChannel methodChannelWithName:kFlutterPlatformChannel
1207 binaryMessenger:self.binaryMessenger
1209 [_platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1210 [weakSelf handleMethodCall:call result:result];
1211 }];
1212}
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMessageCodec > *codec)
instancetype sharedInstance()
instancetype sharedInstance()
void registerWithRegistrar:(nonnull id< FlutterPluginRegistrar > registrar)
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)
void registerWithRegistrar:delegate:(nonnull id< FlutterPluginRegistrar > registrar,[delegate] nullable id< FlutterMouseCursorPluginDelegate > delegate)
fml::scoped_nsobject< FlutterBasicMessageChannel > _settingsChannel
fml::scoped_nsobject< FlutterMethodChannel > _platformChannel

◆ addViewController:

- (void) addViewController: (FlutterViewController *)  viewController
implementation

Attach a view controller to the engine as its default controller.

Since FlutterEngine can only handle the implicit view for now, the given controller will always be assigned to the implicit view, if there isn't an implicit view yet. If the engine already has an implicit view, this call throws an assertion.

The engine holds a weak reference to the attached view controller.

If the given view controller is already attached to an engine, this call throws an assertion.

Definition at line 484 of file FlutterEngine.mm.

891 :(FlutterViewController*)controller {
892 // FlutterEngine can only handle the implicit view for now. Adding more views
893 // throws an assertion.
894 NSAssert(self.viewController == nil,
895 @"The engine already has a view controller for the implicit view.");
896 self.viewController = controller;
897}
FlutterViewController * viewController

◆ announceAccessibilityMessage:withPriority:

- (void) announceAccessibilityMessage: (NSString *)  message
withPriority: (NSAccessibilityPriorityLevel)  priority 
implementation

Announces accessibility messages.

Definition at line 484 of file FlutterEngine.mm.

1262 :(NSString*)message
1263 withPriority:(NSAccessibilityPriorityLevel)priority {
1264 NSAccessibilityPostNotificationWithUserInfo(
1265 [self viewControllerForIdentifier:kFlutterImplicitViewId].flutterView,
1266 NSAccessibilityAnnouncementRequestedNotification,
1267 @{NSAccessibilityAnnouncementKey : message, NSAccessibilityPriorityKey : @(priority)});
1268}
static constexpr FlutterViewId kFlutterImplicitViewId
Definition: embedder.cc:108
Win32Message message

◆ applicationDidEnterBackground:

- (void) applicationDidEnterBackground: (NSNotification*)  notification
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1369 :(NSNotification*)notification {
1370 [self flutterDidEnterBackground:notification];
1371}

◆ applicationWillEnterForeground:

- (void) applicationWillEnterForeground: (NSNotification*)  notification
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1365 :(NSNotification*)notification {
1366 [self flutterWillEnterForeground:notification];
1367}

◆ applicationWillTerminate:

- (void) applicationWillTerminate: (NSNotification*)  notification
implementation

Definition at line 484 of file FlutterEngine.mm.

1221 :(NSNotification*)notification {
1222 [self shutDownEngine];
1223}

◆ attachView

- (void) attachView
implementation

Definition at line 157 of file FlutterEngine.mm.

449 {
450 self.iosPlatformView->attachView();
451}

◆ cleanUpConnection:

- (void) cleanUpConnection: (FlutterBinaryMessengerConnection connection
implementation

Clears out a channel's message handler if that handler is still the one that was created as a result of setMessageHandlerOnChannel:binaryMessageHandler:.

Parameters
connectionThe result from setMessageHandlerOnChannel:binaryMessageHandler:.

Reimplemented from <FlutterBinaryMessenger>.

Definition at line 822 of file FlutterEngine.mm.

1298 if (_shell && _shell->IsSetup()) {
1299 std::string channel = _connections->CleanupConnection(connection);
1300 if (!channel.empty()) {
1301 self.iosPlatformView->GetPlatformMessageHandlerIos()->SetMessageHandler(channel.c_str(), nil,
1302 nil);
1303 }
1304 }
1305}
int64_t FlutterBinaryMessengerConnection
std::unique_ptr< flutter::Shell > _shell
std::unique_ptr< flutter::ConnectionCollection > _connections

◆ clipboardHasStrings

- (BOOL) clipboardHasStrings
implementation

Definition at line 484 of file FlutterEngine.mm.

1326 {
1327 return [self.pasteboard stringForType:NSPasteboardTypeString].length > 0;
1328}

◆ createFlutterCompositor

- (FlutterCompositor *) createFlutterCompositor
implementation

Definition at line 484 of file FlutterEngine.mm.

854 {
855 _macOSCompositor = std::make_unique<flutter::FlutterCompositor>(
856 [[FlutterViewEngineProvider alloc] initWithEngine:self],
857 [[FlutterTimeConverter alloc] initWithEngine:self], _platformViewController);
858
859 _compositor = {};
862
864 FlutterBackingStore* backing_store_out, //
865 void* user_data //
866 ) {
867 return reinterpret_cast<flutter::FlutterCompositor*>(user_data)->CreateBackingStore(
868 config, backing_store_out);
869 };
870
872 void* user_data //
873 ) { return true; };
874
876 return reinterpret_cast<flutter::FlutterCompositor*>(info->user_data)
877 ->Present(info->view_id, info->layers, info->layers_count);
878 };
879
881
882 return &_compositor;
883}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
Converts between the time representation used by Flutter Engine and CAMediaTime.
std::unique_ptr< flutter::FlutterCompositor > _macOSCompositor
FlutterPlatformViewController * _platformViewController
FlutterCompositor _compositor
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition: embedder.h:1903
bool avoid_backing_store_cache
Avoid caching backing stores provided by this compositor.
Definition: embedder.h:1923
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition: embedder.h:1887
FlutterPresentViewCallback present_view_callback
Definition: embedder.h:1932
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition: embedder.h:1908
void * user_data

◆ createShell:libraryURI:initialRoute:

- (BOOL) createShell: (NSString*)  entrypoint
libraryURI: (NSString*)  libraryURI
initialRoute: (NSString*)  initialRoute 
implementation

Definition at line 822 of file FlutterEngine.mm.

836 :(NSString*)entrypoint
837 libraryURI:(NSString*)libraryURI
838 initialRoute:(NSString*)initialRoute {
839 if (_shell != nullptr) {
840 FML_LOG(WARNING) << "This FlutterEngine was already invoked.";
841 return NO;
842 }
843
844 self.initialRoute = initialRoute;
845
846 auto settings = [_dartProject.get() settings];
847 if (initialRoute != nil) {
848 self.initialRoute = initialRoute;
849 } else if (settings.route.empty() == false) {
850 self.initialRoute = [NSString stringWithUTF8String:settings.route.c_str()];
851 }
852
853 FlutterView.forceSoftwareRendering = settings.enable_software_rendering;
854
855 auto platformData = [_dartProject.get() defaultPlatformData];
856
857 SetEntryPoint(&settings, entrypoint, libraryURI);
858
859 NSString* threadLabel = [FlutterEngine generateThreadLabel:_labelPrefix];
860 _threadHost = std::make_shared<flutter::ThreadHost>();
862
863 // Lambda captures by pointers to ObjC objects are fine here because the
864 // create call is synchronous.
866 [self](flutter::Shell& shell) {
867 [self recreatePlatformViewController];
868 return std::make_unique<flutter::PlatformViewIOS>(
869 shell, self->_renderingApi, self->_platformViewsController, shell.GetTaskRunners(),
871 };
872
874 [](flutter::Shell& shell) { return std::make_unique<flutter::Rasterizer>(shell); };
875
876 flutter::TaskRunners task_runners(threadLabel.UTF8String, // label
878 _threadHost->raster_thread->GetTaskRunner(), // raster
879 _threadHost->ui_thread->GetTaskRunner(), // ui
880 _threadHost->io_thread->GetTaskRunner() // io
881 );
882
883#if APPLICATION_EXTENSION_API_ONLY
884 if (@available(iOS 13.0, *)) {
885 _isGpuDisabled = self.viewController.flutterWindowSceneIfViewLoaded.activationState ==
886 UISceneActivationStateBackground;
887 } else {
888 // [UIApplication sharedApplication API is not available for app extension.
889 // We intialize the shell assuming the GPU is required.
890 _isGpuDisabled = NO;
891 }
892#else
893 _isGpuDisabled =
894 [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
895#endif
896
897 // Create the shell. This is a blocking operation.
898 std::unique_ptr<flutter::Shell> shell = flutter::Shell::Create(
899 /*platform_data=*/platformData,
900 /*task_runners=*/task_runners,
901 /*settings=*/settings,
902 /*on_create_platform_view=*/on_create_platform_view,
903 /*on_create_rasterizer=*/on_create_rasterizer,
904 /*is_gpu_disabled=*/_isGpuDisabled);
905
906 if (shell == nullptr) {
907 FML_LOG(ERROR) << "Could not start a shell FlutterEngine with entrypoint: "
908 << entrypoint.UTF8String;
909 } else {
910 // TODO(vashworth): Remove once done debugging https://github.com/flutter/flutter/issues/129836
911 FML_LOG(INFO) << "Enabled VM Service Publication: " << settings.enable_vm_service_publication;
912 [self setUpShell:std::move(shell)
913 withVMServicePublication:settings.enable_vm_service_publication];
915 [self startProfiler];
916 }
917 }
918
919 return _shell != nullptr;
920}
flutter::Shell & shell()
static std::unique_ptr< Shell > Create(const PlatformData &platform_data, const TaskRunners &task_runners, Settings settings, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer, bool is_gpu_disabled=false)
Creates a shell instance using the provided settings. The callbacks to create the various shell subco...
Definition: shell.cc:169
const std::shared_ptr< fml::ConcurrentTaskRunner > GetConcurrentWorkerTaskRunner() const
Definition: shell.cc:2334
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
Definition: shell.cc:805
std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const override
Accessor for the disable GPU SyncSwitch.
Definition: shell.cc:2267
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition: shell.h:120
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
#define FML_LOG(severity)
Definition: logging.h:82
NSString * initialRoute
BOOL isProfilerEnabled()
static void SetEntryPoint(flutter::Settings *settings, NSString *entrypoint, NSString *libraryURI)
NSString * generateThreadLabel:(NSString *labelPrefix)
flutter::ThreadHost makeThreadHost:(NSString *threadLabel)
BOOL forceSoftwareRendering
Definition: FlutterView.h:49
std::shared_ptr< flutter::ThreadHost > _threadHost
#define ERROR(message)
Definition: elf_loader.cc:260

◆ dealloc

- (void) dealloc
implementation

Notify plugins of dealloc. This should happen first in dealloc since the plugins may be talking to things like the binaryMessenger.

nil out weak references.

Definition at line 157 of file FlutterEngine.mm.

281 {
282 /// Notify plugins of dealloc. This should happen first in dealloc since the
283 /// plugins may be talking to things like the binaryMessenger.
284 [_pluginPublications enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL* stop) {
285 if ([object respondsToSelector:@selector(detachFromEngineForRegistrar:)]) {
286 NSObject<FlutterPluginRegistrar>* registrar = self.registrars[key];
287 [object detachFromEngineForRegistrar:registrar];
288 }
289 }];
290
291 [[NSNotificationCenter defaultCenter] postNotificationName:kFlutterEngineWillDealloc
292 object:self
293 userInfo:nil];
294
295 // It will be destroyed and invalidate its weak pointers
296 // before any other members are destroyed.
297 _weakFactory.reset();
298
299 /// nil out weak references.
300 [_registrars
301 enumerateKeysAndObjectsUsingBlock:^(id key, FlutterEngineRegistrar* registrar, BOOL* stop) {
302 registrar.flutterEngine = nil;
303 }];
304
305 [_labelPrefix release];
306 [_initialRoute release];
307 [_pluginPublications release];
308 [_registrars release];
311 [_binaryMessenger release];
312 [_textureRegistry release];
313 _textureRegistry = nil;
314 [_isolateId release];
315
316 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
317 if (_flutterViewControllerWillDeallocObserver) {
318 [center removeObserver:_flutterViewControllerWillDeallocObserver];
319 [_flutterViewControllerWillDeallocObserver release];
320 }
321 [center removeObserver:self];
322
323 [super dealloc];
324}
static SkScalar center(float pos0, float pos1)
NSObject< FlutterBinaryMessenger > * parent
NSObject< FlutterTextureRegistry > * parent
std::unique_ptr< fml::WeakNSObjectFactory< FlutterEngine > > _weakFactory
FlutterTextureRegistryRelay * _textureRegistry
FlutterBinaryMessengerRelay * _binaryMessenger

◆ deregisterViewControllerForIdentifier:

- (void) deregisterViewControllerForIdentifier: (FlutterViewIdentifier viewIdentifier
implementation

An internal method that removes the view controller with the given ID.

This method clears the ID of the controller, removes the controller from the map. This is an no-op if the view ID is not associated with any view controllers.

Definition at line 484 of file FlutterEngine.mm.

787 :(FlutterViewIdentifier)viewIdentifier {
788 FlutterViewController* controller = [self viewControllerForIdentifier:viewIdentifier];
789 // The controller can be nil. The engine stores only a weak ref, and this
790 // method could have been called from the controller's dealloc.
791 if (controller != nil) {
792 [controller detachFromEngine];
793 NSAssert(!controller.attached,
794 @"The FlutterViewController unexpectedly stays attached after being removed. "
795 @"In unit tests, this is likely because either the FlutterViewController or "
796 @"the FlutterEngine is mocked. Please subclass these classes instead.");
797 }
798 [_viewControllers removeObjectForKey:@(viewIdentifier)];
799 @synchronized(_vsyncWaiters) {
800 [_vsyncWaiters removeObjectForKey:@(viewIdentifier)];
801 }
802}
int64_t FlutterViewIdentifier
NSMapTable< NSNumber *, FlutterVSyncWaiter * > * _vsyncWaiters

◆ destroyContext

- (void) destroyContext

Destroy running context for an engine.

This method can be used to force the FlutterEngine object to release all resources. After sending this message, the object will be in an unusable state until it is deallocated. Accessing properties or sending messages to it will result in undefined behavior or runtime errors.

Definition at line 157 of file FlutterEngine.mm.

479 {
480 [self resetChannels];
481 self.isolateId = nil;
482 _shell.reset();
483 _profiler.reset();
484 _threadHost.reset();
486}
std::shared_ptr< flutter::SamplingProfiler > _profiler
std::shared_ptr< flutter::FlutterPlatformViewsController > _platformViewsController

◆ didUpdateMouseCursor:

- (void) didUpdateMouseCursor: (NSCursor*)  cursor
implementation

Definition at line 484 of file FlutterEngine.mm.

1214 :(NSCursor*)cursor {
1215 // Mouse cursor plugin does not specify which view is responsible for changing the cursor,
1216 // so the reasonable assumption here is that cursor change is a result of a mouse movement
1217 // and thus the cursor will be paired with last Flutter view that reveived mouse event.
1218 [_lastViewWithPointerEvent didUpdateMouseCursor:cursor];
1219}

◆ dispatchPointerDataPacket:

- (void) dispatchPointerDataPacket: (std::unique_ptr<flutter::PointerDataPacket>)  packet
implementation

Definition at line 157 of file FlutterEngine.mm.

342 :(std::unique_ptr<flutter::PointerDataPacket>)packet {
343 if (!self.platformView) {
344 return;
345 }
346 self.platformView->DispatchPointerDataPacket(std::move(packet));
347}
fml::WeakPtr< flutter::PlatformView > platformView()

◆ dispatchSemanticsAction:toTarget:withData:

- (void) dispatchSemanticsAction: (FlutterSemanticsAction action
toTarget: (uint16_t)  target
withData: (fml::MallocMapping data 
implementation

Dispatches semantics action back to the framework. The semantics must be enabled by calling the updateSemanticsEnabled before dispatching semantics actions.

Definition at line 484 of file FlutterEngine.mm.

1037 toTarget:(uint16_t)target
1038 withData:(fml::MallocMapping)data {
1039 _embedderAPI.DispatchSemanticsAction(_engine, target, action, data.GetMapping(), data.GetSize());
1040}
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition: mapping.h:144
FlutterSemanticsAction
Definition: embedder.h:113
uint32_t * target
fml::scoped_nsobject< FlutterEngine > _engine
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ embedderAPI

- (FlutterEngineProcTable &) embedderAPI
implementation

Function pointers for interacting with the embedder.h API.

Provided by category FlutterEngine(Test).

Definition at line 484 of file FlutterEngine.mm.

977 {
978 return _embedderAPI;
979}

◆ engineCallbackOnPlatformMessage:

- (void) engineCallbackOnPlatformMessage: (const FlutterPlatformMessage *)  message
implementation

Handles a platform message from the engine.

Definition at line 484 of file FlutterEngine.mm.

1072 NSData* messageData = nil;
1073 if (message->message_size > 0) {
1074 messageData = [NSData dataWithBytesNoCopy:(void*)message->message
1075 length:message->message_size
1076 freeWhenDone:NO];
1077 }
1078 NSString* channel = @(message->channel);
1079 __block const FlutterPlatformMessageResponseHandle* responseHandle = message->response_handle;
1080 __block FlutterEngine* weakSelf = self;
1081 NSMutableArray* isResponseValid = self.isResponseValid;
1082 FlutterEngineSendPlatformMessageResponseFnPtr sendPlatformMessageResponse =
1083 _embedderAPI.SendPlatformMessageResponse;
1084 FlutterBinaryReply binaryResponseHandler = ^(NSData* response) {
1085 @synchronized(isResponseValid) {
1086 if (![isResponseValid[0] boolValue]) {
1087 // Ignore, engine was killed.
1088 return;
1089 }
1090 if (responseHandle) {
1091 sendPlatformMessageResponse(weakSelf->_engine, responseHandle,
1092 static_cast<const uint8_t*>(response.bytes), response.length);
1093 responseHandle = NULL;
1094 } else {
1095 NSLog(@"Error: Message responses can be sent only once. Ignoring duplicate response "
1096 "on channel '%@'.",
1097 channel);
1098 }
1099 }
1100 };
1101
1102 FlutterEngineHandlerInfo* handlerInfo = _messengerHandlers[channel];
1103 if (handlerInfo) {
1104 handlerInfo.handler(messageData, binaryResponseHandler);
1105 } else {
1106 binaryResponseHandler(nil);
1107 }
1108}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
FlutterEngineResult(* FlutterEngineSendPlatformMessageResponseFnPtr)(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: embedder.h:3240
FlutterBinaryMessageHandler handler
NSMutableArray< NSNumber * > * isResponseValid
NSMutableDictionary< NSString *, FlutterEngineHandlerInfo * > * _messengerHandlers

◆ engineCallbackOnPreEngineRestart

- (void) engineCallbackOnPreEngineRestart
implementation

Invoked right before the engine is restarted.

This should reset states to as if the application has just started. It usually indicates a hot restart (Shift-R in Flutter CLI.)

Definition at line 484 of file FlutterEngine.mm.

1110 {
1111 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1112 FlutterViewController* nextViewController;
1113 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1114 [nextViewController onPreEngineRestart];
1115 }
1116}

◆ ensureSemanticsEnabled

- (void) ensureSemanticsEnabled

Ensures that Flutter will generate a semantics tree.

This is enabled by default if certain accessibility services are turned on by the user, or when using a Simulator. This method allows a user to turn semantics on when they would not ordinarily be generated and the performance overhead is not a concern, e.g. for UI testing. Note that semantics should never be programmatically turned off, as it would potentially disable accessibility services an end user has requested.

This method must only be called after launching the engine via -runWithEntrypoint: or -runWithEntryPoint:libraryURI.

Although this method returns synchronously, it does not guarantee that a semantics tree is actually available when the method returns. It synchronously ensures that the next frame the Flutter framework creates will have a semantics tree.

You can subscribe to semantics updates via NSNotificationCenter by adding an observer for the name FlutterSemanticsUpdateNotification. The object parameter will be the FlutterViewController associated with the semantics update. This will asynchronously fire after a semantics tree has actually built (which may be some time after the frame has been rendered).

Reimplemented in FlutterEngineSpy.

Definition at line 157 of file FlutterEngine.mm.

421 {
422 self.iosPlatformView->SetSemanticsEnabled(true);
423}

◆ executableName

- (nonnull NSString *) executableName
implementation

The executable name for the current process.

Definition at line 484 of file FlutterEngine.mm.

981 {
982 return [[[NSProcessInfo processInfo] arguments] firstObject] ?: @"Flutter";
983}

◆ FLUTTER_DEPRECATED

- (NSURL *observatoryUrl) FLUTTER_DEPRECATED ("Use vmServiceUrl instead") 

The depcreated NSURL of the Dart VM Service for the service isolate.

This is only set in debug and profile runtime modes, and only after the Dart VM Service is ready. In release mode or before the Dart VM Service has started, it returns nil.

◆ flutterDidEnterBackground:

- (void) flutterDidEnterBackground: (NSNotification*)  notification
implementation

Definition at line 822 of file FlutterEngine.mm.

1378 :(NSNotification*)notification {
1379 [self setIsGpuDisabled:YES];
1380 [self notifyLowMemory];
1381}

◆ flutterTextInputPlugin:focusElement:atPoint:result:

- (void) flutterTextInputPlugin: (FlutterTextInputPlugin*)  textInputPlugin
focusElement: (UIScribbleElementIdentifier)  elementIdentifier
atPoint: (CGPoint)  referencePoint
result: (FlutterResult callback 
implementation

Reimplemented from <FlutterIndirectScribbleDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1099 focusElement:(UIScribbleElementIdentifier)elementIdentifier
1100 atPoint:(CGPoint)referencePoint
1102 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1103 // the framework has finished transitioning to the Scribble channel.
1104 // https://github.com/flutter/flutter/pull/115296
1105 [_textInputChannel.get()
1106 invokeMethod:@"TextInputClient.focusElement"
1107 arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
1108 result:callback];
1109}
void(^ FlutterResult)(id _Nullable result)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
FlutterTextInputPlugin * textInputPlugin()

◆ flutterTextInputPlugin:requestElementsInRect:result:

- (void) flutterTextInputPlugin: (FlutterTextInputPlugin*)  textInputPlugin
requestElementsInRect: (CGRect)  rect
result: (FlutterResult callback 
implementation

Reimplemented from <FlutterIndirectScribbleDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1112 requestElementsInRect:(CGRect)rect
1114 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1115 // the framework has finished transitioning to the Scribble channel.
1116 // https://github.com/flutter/flutter/pull/115296
1117 [_textInputChannel.get()
1118 invokeMethod:@"TextInputClient.requestElementsInRect"
1119 arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
1120 result:callback];
1121}
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ flutterTextInputView:didResignFirstResponderWithTextInputClient:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
didResignFirstResponderWithTextInputClient: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1157 :(FlutterTextInputView*)textInputView
1158 didResignFirstResponderWithTextInputClient:(int)client {
1159 // When flutter text input view resign first responder, send a message to
1160 // framework to ensure the focus state is correct. This is useful when close
1161 // keyboard from platform side.
1162 [_textInputChannel.get() invokeMethod:@"TextInputClient.onConnectionClosed"
1163 arguments:@[ @(client) ]];
1164
1165 // Platform view's first responder detection logic:
1166 //
1167 // All text input widgets (e.g. EditableText) are backed by a dummy UITextInput view
1168 // in the TextInputPlugin. When this dummy UITextInput view resigns first responder,
1169 // check if any platform view becomes first responder. If any platform view becomes
1170 // first responder, send a "viewFocused" channel message to inform the framework to un-focus
1171 // the previously focused text input.
1172 //
1173 // Caveat:
1174 // 1. This detection logic does not cover the scenario when a platform view becomes
1175 // first responder without any flutter text input resigning its first responder status
1176 // (e.g. user tapping on platform view first). For now it works fine because the TextInputPlugin
1177 // does not track the focused platform view id (which is different from Android implementation).
1178 //
1179 // 2. This detection logic assumes that all text input widgets are backed by a dummy
1180 // UITextInput view in the TextInputPlugin, which may not hold true in the future.
1181
1182 // Have to check in the next run loop, because iOS requests the previous first responder to
1183 // resign before requesting the next view to become first responder.
1184 dispatch_async(dispatch_get_main_queue(), ^(void) {
1185 long platform_view_id = self.platformViewsController->FindFirstResponderPlatformViewId();
1186 if (platform_view_id == -1) {
1187 return;
1188 }
1189
1190 [_platformViewsChannel.get() invokeMethod:@"viewFocused" arguments:@(platform_view_id)];
1191 });
1192}

◆ flutterTextInputView:insertTextPlaceholderWithSize:withClient:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
insertTextPlaceholderWithSize: (CGSize)  size
withClient: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1138 :(FlutterTextInputView*)textInputView
1139 insertTextPlaceholderWithSize:(CGSize)size
1140 withClient:(int)client {
1141 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1142 // the framework has finished transitioning to the Scribble channel.
1143 // https://github.com/flutter/flutter/pull/115296
1144 [_textInputChannel.get() invokeMethod:@"TextInputClient.insertTextPlaceholder"
1145 arguments:@[ @(client), @(size.width), @(size.height) ]];
1146}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ flutterTextInputView:performAction:withClient:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
performAction: (FlutterTextInputAction)  action
withClient: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1028 :(FlutterTextInputView*)textInputView
1029 performAction:(FlutterTextInputAction)action
1030 withClient:(int)client {
1031 NSString* actionString;
1032 switch (action) {
1033 case FlutterTextInputActionUnspecified:
1034 // Where did the term "unspecified" come from? iOS has a "default" and Android
1035 // has "unspecified." These 2 terms seem to mean the same thing but we need
1036 // to pick just one. "unspecified" was chosen because "default" is often a
1037 // reserved word in languages with switch statements (dart, java, etc).
1038 actionString = @"TextInputAction.unspecified";
1039 break;
1040 case FlutterTextInputActionDone:
1041 actionString = @"TextInputAction.done";
1042 break;
1043 case FlutterTextInputActionGo:
1044 actionString = @"TextInputAction.go";
1045 break;
1046 case FlutterTextInputActionSend:
1047 actionString = @"TextInputAction.send";
1048 break;
1049 case FlutterTextInputActionSearch:
1050 actionString = @"TextInputAction.search";
1051 break;
1052 case FlutterTextInputActionNext:
1053 actionString = @"TextInputAction.next";
1054 break;
1055 case FlutterTextInputActionContinue:
1056 actionString = @"TextInputAction.continueAction";
1057 break;
1058 case FlutterTextInputActionJoin:
1059 actionString = @"TextInputAction.join";
1060 break;
1061 case FlutterTextInputActionRoute:
1062 actionString = @"TextInputAction.route";
1063 break;
1064 case FlutterTextInputActionEmergencyCall:
1065 actionString = @"TextInputAction.emergencyCall";
1066 break;
1067 case FlutterTextInputActionNewline:
1068 actionString = @"TextInputAction.newline";
1069 break;
1070 }
1071 [_textInputChannel.get() invokeMethod:@"TextInputClient.performAction"
1072 arguments:@[ @(client), actionString ]];
1073}

◆ flutterTextInputView:removeTextPlaceholder:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
removeTextPlaceholder: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1148 :(FlutterTextInputView*)textInputView
1149 removeTextPlaceholder:(int)client {
1150 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1151 // the framework has finished transitioning to the Scribble channel.
1152 // https://github.com/flutter/flutter/pull/115296
1153 [_textInputChannel.get() invokeMethod:@"TextInputClient.removeTextPlaceholder"
1154 arguments:@[ @(client) ]];
1155}

◆ flutterTextInputView:showAutocorrectionPromptRectForStart:end:withClient:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
showAutocorrectionPromptRectForStart: (NSUInteger)  start
end: (NSUInteger)  end
withClient: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1075 :(FlutterTextInputView*)textInputView
1076 showAutocorrectionPromptRectForStart:(NSUInteger)start
1077 end:(NSUInteger)end
1078 withClient:(int)client {
1079 [_textInputChannel.get() invokeMethod:@"TextInputClient.showAutocorrectionPromptRect"
1080 arguments:@[ @(client), @(start), @(end) ]];
1081}
glong glong end

◆ flutterTextInputView:showToolbar:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
showToolbar: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1091 :(FlutterTextInputView*)textInputView showToolbar:(int)client {
1092 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1093 // the framework has finished transitioning to the Scribble channel.
1094 // https://github.com/flutter/flutter/pull/115296
1095 [_textInputChannel.get() invokeMethod:@"TextInputClient.showToolbar" arguments:@[ @(client) ]];
1096}

◆ flutterTextInputView:updateEditingClient:withDelta:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
updateEditingClient: (int client
withDelta: (NSDictionary*)  delta 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1001 :(FlutterTextInputView*)textInputView
1002 updateEditingClient:(int)client
1003 withDelta:(NSDictionary*)delta {
1004 [_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingStateWithDeltas"
1005 arguments:@[ @(client), delta ]];
1006}

◆ flutterTextInputView:updateEditingClient:withState:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
updateEditingClient: (int client
withState: (NSDictionary*)  state 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

986 :(FlutterTextInputView*)textInputView
987 updateEditingClient:(int)client
988 withState:(NSDictionary*)state {
989 [_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingState"
990 arguments:@[ @(client), state ]];
991}
AtkStateType state

◆ flutterTextInputView:updateEditingClient:withState:withTag:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
updateEditingClient: (int client
withState: (NSDictionary*)  state
withTag: (NSString*)  tag 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

993 :(FlutterTextInputView*)textInputView
994 updateEditingClient:(int)client
995 withState:(NSDictionary*)state
996 withTag:(NSString*)tag {
997 [_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingStateWithTag"
998 arguments:@[ @(client), @{tag : state} ]];
999}

◆ flutterTextInputView:updateFloatingCursor:withClient:withPosition:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
updateFloatingCursor: (FlutterFloatingCursorDragState)  state
withClient: (int client
withPosition: (NSDictionary*)  position 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1008 :(FlutterTextInputView*)textInputView
1009 updateFloatingCursor:(FlutterFloatingCursorDragState)state
1010 withClient:(int)client
1011 withPosition:(NSDictionary*)position {
1012 NSString* stateString;
1013 switch (state) {
1014 case FlutterFloatingCursorDragStateStart:
1015 stateString = @"FloatingCursorDragState.start";
1016 break;
1017 case FlutterFloatingCursorDragStateUpdate:
1018 stateString = @"FloatingCursorDragState.update";
1019 break;
1020 case FlutterFloatingCursorDragStateEnd:
1021 stateString = @"FloatingCursorDragState.end";
1022 break;
1023 }
1024 [_textInputChannel.get() invokeMethod:@"TextInputClient.updateFloatingCursor"
1025 arguments:@[ @(client), stateString, position ]];
1026}

◆ flutterTextInputView:willDismissEditMenuWithTextInputClient:

- (void) flutterTextInputView: (FlutterTextInputView*)  textInputView
willDismissEditMenuWithTextInputClient: (int client 
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1083 :(FlutterTextInputView*)textInputView
1084 willDismissEditMenuWithTextInputClient:(int)client {
1085 [_platformChannel.get() invokeMethod:@"ContextMenu.onDismissSystemContextMenu"
1086 arguments:@[ @(client) ]];
1087}

◆ flutterTextInputViewScribbleInteractionBegan:

- (void) flutterTextInputViewScribbleInteractionBegan: (FlutterTextInputView*)  textInputView
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1123 :(FlutterTextInputView*)textInputView {
1124 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1125 // the framework has finished transitioning to the Scribble channel.
1126 // https://github.com/flutter/flutter/pull/115296
1127 [_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionBegan" arguments:nil];
1128}

◆ flutterTextInputViewScribbleInteractionFinished:

- (void) flutterTextInputViewScribbleInteractionFinished: (FlutterTextInputView*)  textInputView
implementation

Reimplemented from <FlutterTextInputDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1130 :(FlutterTextInputView*)textInputView {
1131 // TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1132 // the framework has finished transitioning to the Scribble channel.
1133 // https://github.com/flutter/flutter/pull/115296
1134 [_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionFinished"
1135 arguments:nil];
1136}

◆ flutterViewAccessibilityDidCall

- (void) flutterViewAccessibilityDidCall
implementation

A callback that is called when iOS queries accessibility information of the Flutter view.

This is useful to predict the current iOS accessibility status. For example, there is no API to listen whether voice control is turned on or off. The Flutter engine uses this callback to enable semantics in order to catch the case that voice control is on.

Reimplemented from <FlutterViewEngineDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1217 {
1218 if (self.viewController.view.accessibilityElements == nil) {
1219 [self ensureSemanticsEnabled];
1220 }
1221}

◆ flutterWillEnterForeground:

- (void) flutterWillEnterForeground: (NSNotification*)  notification
implementation

Definition at line 822 of file FlutterEngine.mm.

1374 :(NSNotification*)notification {
1375 [self setIsGpuDisabled:NO];
1376}

◆ generateThreadLabel:

+ (NSString *) generateThreadLabel: (NSString*)  labelPrefix
implementation

Definition at line 157 of file FlutterEngine.mm.

784 :(NSString*)labelPrefix {
785 static size_t s_shellCount = 0;
786 return [NSString stringWithFormat:@"%@.%zu", labelPrefix, ++s_shellCount];
787}

◆ getClipboardData:

- (NSDictionary *) getClipboardData: (NSString*)  format
implementation

Definition at line 484 of file FlutterEngine.mm.

1310 :(NSString*)format {
1311 if ([format isEqualToString:@(kTextPlainFormat)]) {
1312 NSString* stringInPasteboard = [self.pasteboard stringForType:NSPasteboardTypeString];
1313 return stringInPasteboard == nil ? nil : @{@"text" : stringInPasteboard};
1314 }
1315 return nil;
1316}
uint32_t uint32_t * format
constexpr char kTextPlainFormat[]
Clipboard plain text format.

◆ getWeakNSObject

- (WeakNSObject< FlutterEngine >) FlutterEngine:
implementation

Definition at line 157 of file FlutterEngine.mm.

331 {
332 return _weakFactory->GetWeakNSObject();
333}

◆ handleAccessibilityEvent:

- (void) handleAccessibilityEvent: (NSDictionary< NSString *, id > *)  annotatedEvent
implementation

Handles accessibility events.

Definition at line 484 of file FlutterEngine.mm.

1245 :(NSDictionary<NSString*, id>*)annotatedEvent {
1246 NSString* type = annotatedEvent[@"type"];
1247 if ([type isEqualToString:@"announce"]) {
1248 NSString* message = annotatedEvent[@"data"][@"message"];
1249 NSNumber* assertiveness = annotatedEvent[@"data"][@"assertiveness"];
1250 if (message == nil) {
1251 return;
1252 }
1253
1254 NSAccessibilityPriorityLevel priority = [assertiveness isEqualToNumber:@1]
1255 ? NSAccessibilityPriorityHigh
1256 : NSAccessibilityPriorityMedium;
1257
1258 [self announceAccessibilityMessage:message withPriority:priority];
1259 }
1260}
GLenum type

◆ handleDidChangeOcclusionState:

- (void) handleDidChangeOcclusionState: (NSNotification*)  notification
implementation

Called when the |FlutterAppDelegate| gets the applicationDidUnhide notification.

Definition at line 484 of file FlutterEngine.mm.

1377 :(NSNotification*)notification {
1378 NSApplicationOcclusionState occlusionState = [[NSApplication sharedApplication] occlusionState];
1379 if (occlusionState & NSApplicationOcclusionStateVisible) {
1380 _visible = YES;
1381 if (_active) {
1382 [self setApplicationState:flutter::AppLifecycleState::kResumed];
1383 } else {
1384 [self setApplicationState:flutter::AppLifecycleState::kInactive];
1385 }
1386 } else {
1387 _visible = NO;
1388 [self setApplicationState:flutter::AppLifecycleState::kHidden];
1389 }
1390}
BOOL _visible
BOOL _active

◆ handleMethodCall:result:

- (void) handleMethodCall: (FlutterMethodCall *)  call
result: (FlutterResult result 
implementation

Handles messages received from the Flutter engine on the _*Channel channels.

Definition at line 484 of file FlutterEngine.mm.

1270 if ([call.method isEqualToString:@"SystemNavigator.pop"]) {
1271 [[NSApplication sharedApplication] terminate:self];
1272 result(nil);
1273 } else if ([call.method isEqualToString:@"SystemSound.play"]) {
1274 [self playSystemSound:call.arguments];
1275 result(nil);
1276 } else if ([call.method isEqualToString:@"Clipboard.getData"]) {
1277 result([self getClipboardData:call.arguments]);
1278 } else if ([call.method isEqualToString:@"Clipboard.setData"]) {
1279 [self setClipboardData:call.arguments];
1280 result(nil);
1281 } else if ([call.method isEqualToString:@"Clipboard.hasStrings"]) {
1282 result(@{@"value" : @([self clipboardHasStrings])});
1283 } else if ([call.method isEqualToString:@"System.exitApplication"]) {
1284 if ([self terminationHandler] == nil) {
1285 // If the termination handler isn't set, then either we haven't
1286 // initialized it yet, or (more likely) the NSApp delegate isn't a
1287 // FlutterAppDelegate, so it can't cancel requests to exit. So, in that
1288 // case, just terminate when requested.
1289 [NSApp terminate:self];
1290 result(nil);
1291 } else {
1292 [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result];
1293 }
1294 } else if ([call.method isEqualToString:@"System.initializationComplete"]) {
1295 if ([self terminationHandler] != nil) {
1296 [self terminationHandler].acceptingRequests = YES;
1297 }
1298 result(nil);
1299 } else {
1301 }
1302}
FLUTTER_DARWIN_EXPORT NSObject const * FlutterMethodNotImplemented
FlutterEngineTerminationHandler * terminationHandler
def call(args)
Definition: dom.py:159

◆ handleUndoWithDirection:

- (void) handleUndoWithDirection: (FlutterUndoRedoDirection)  direction
implementation

Pass changes to the framework through the undo manager channel.

Reimplemented from <FlutterUndoManagerDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1196 :(FlutterUndoRedoDirection)direction {
1197 NSString* action = (direction == FlutterUndoRedoDirectionUndo) ? @"undo" : @"redo";
1198 [_undoManagerChannel.get() invokeMethod:@"UndoManagerClient.handleUndo" arguments:@[ action ]];
1199}

◆ handleWillBecomeActive:

- (void) handleWillBecomeActive: (NSNotification*)  notification
implementation

Called when the |FlutterAppDelegate| gets the applicationWillBecomeActive notification.

Definition at line 484 of file FlutterEngine.mm.

1351 :(NSNotification*)notification {
1352 _active = YES;
1353 if (!_visible) {
1354 [self setApplicationState:flutter::AppLifecycleState::kHidden];
1355 } else {
1356 [self setApplicationState:flutter::AppLifecycleState::kResumed];
1357 }
1358}

◆ handleWillResignActive:

- (void) handleWillResignActive: (NSNotification*)  notification
implementation

Called when the |FlutterAppDelegate| gets the applicationWillResignActive notification.

Definition at line 484 of file FlutterEngine.mm.

1364 :(NSNotification*)notification {
1365 _active = NO;
1366 if (!_visible) {
1367 [self setApplicationState:flutter::AppLifecycleState::kHidden];
1368 } else {
1369 [self setApplicationState:flutter::AppLifecycleState::kInactive];
1370 }
1371}

◆ hasPlugin:

- (BOOL) hasPlugin: (NSString *)  pluginKey
implementation

Returns whether the specified plugin has been registered.

Parameters
pluginKeyThe unique key identifying the plugin.
Returns
YES if registrarForPlugin has been called with pluginKey.

Reimplemented from <FlutterPluginRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1346 :(NSString*)pluginKey {
1347 return _pluginPublications[pluginKey] != nil;
1348}

◆ init

- (instancetype) init

Default initializer for a FlutterEngine.

Threads created by this FlutterEngine will appear as "FlutterEngine #" in Instruments. The prefix can be customized using initWithName.

The engine will execute the project located in the bundle with the identifier "io.flutter.flutter.app" (the default for Flutter projects).

A newly initialized engine will not run until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI: is called.

FlutterEngine created with this method will have allowHeadlessExecution set to YES. This means that the engine will continue to run regardless of whether a FlutterViewController is attached to it or not, until -destroyContext: is called or the process finishes.

Reimplemented in FlutterHeadlessDartRunner.

Definition at line 157 of file FlutterEngine.mm.

160 {
161 return [self initWithName:@"FlutterEngine" project:nil allowHeadlessExecution:YES];
162}

◆ initWithName:

- (instancetype) initWithName: (NSString*)  labelPrefix

Initialize this FlutterEngine.

The engine will execute the project located in the bundle with the identifier "io.flutter.flutter.app" (the default for Flutter projects).

A newly initialized engine will not run until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI: is called.

FlutterEngine created with this method will have allowHeadlessExecution set to YES. This means that the engine will continue to run regardless of whether a FlutterViewController is attached to it or not, until -destroyContext: is called or the process finishes.

Parameters
labelPrefixThe label prefix used to identify threads for this instance. Should be unique across FlutterEngine instances, and is used in instrumentation to label the threads used by this FlutterEngine.

Definition at line 157 of file FlutterEngine.mm.

164 :(NSString*)labelPrefix {
165 return [self initWithName:labelPrefix project:nil allowHeadlessExecution:YES];
166}

◆ initWithName:project: [1/3]

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

Initializes an engine with the given project.

Parameters
labelPrefixCurrently unused; in the future, may be used for labelling threads as with the iOS FlutterEngine.
projectThe project configuration. If nil, a default FlutterDartProject will be used.

◆ initWithName:project: [2/3]

- (instancetype) initWithName: (NSString*)  labelPrefix
project: (FlutterDartProject*)  project 
implementation

Reimplemented in FlutterHeadlessDartRunner.

Definition at line 157 of file FlutterEngine.mm.

168 :(NSString*)labelPrefix project:(FlutterDartProject*)project {
169 return [self initWithName:labelPrefix project:project allowHeadlessExecution:YES];
170}
FlutterDartProject * project()

◆ initWithName:project: [3/3]

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

Initialize this FlutterEngine with a FlutterDartProject.

If the FlutterDartProject is not specified, the FlutterEngine will attempt to locate the project in a default location (the flutter_assets folder in the iOS application bundle).

A newly initialized engine will not run the FlutterDartProject until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI: is called.

FlutterEngine created with this method will have allowHeadlessExecution set to YES. This means that the engine will continue to run regardless of whether a FlutterViewController is attached to it or not, until -destroyContext: is called or the process finishes.

Parameters
labelPrefixThe label prefix used to identify threads for this instance. Should be unique across FlutterEngine instances, and is used in instrumentation to label the threads used by this FlutterEngine.
projectThe FlutterDartProject to run.

◆ initWithName:project:allowHeadlessExecution: [1/3]

- (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
labelPrefixCurrently unused; in the future, may be used for labelling threads as with the iOS FlutterEngine.
projectThe project configuration. If nil, a default FlutterDartProject will be used.

◆ initWithName:project:allowHeadlessExecution: [2/3]

- (instancetype) initWithName: (NSString*)  labelPrefix
project: (FlutterDartProject*)  project
allowHeadlessExecution: (BOOL allowHeadlessExecution 
implementation

Reimplemented in FlutterHeadlessDartRunner.

Definition at line 157 of file FlutterEngine.mm.

172 :(NSString*)labelPrefix
174 allowHeadlessExecution:(BOOL)allowHeadlessExecution {
175 return [self initWithName:labelPrefix
176 project:project
177 allowHeadlessExecution:allowHeadlessExecution
178 restorationEnabled:NO];
179}
int BOOL
Definition: windows_types.h:37

◆ initWithName:project:allowHeadlessExecution: [3/3]

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

Initialize this FlutterEngine with a FlutterDartProject.

If the FlutterDartProject is not specified, the FlutterEngine will attempt to locate the project in a default location (the flutter_assets folder in the iOS application bundle).

A newly initialized engine will not run the FlutterDartProject until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI: is called.

Parameters
labelPrefixThe label prefix used to identify threads for this instance. Should be unique across FlutterEngine instances, and is used in instrumentation to label the threads used by this FlutterEngine.
projectThe FlutterDartProject to run.
allowHeadlessExecutionWhether or not to allow this instance to continue running after passing a nil FlutterViewController to -setViewController:.

◆ initWithName:project:allowHeadlessExecution:restorationEnabled: [1/2]

- (instancetype) initWithName: (NSString*)  labelPrefix
project: (FlutterDartProject*)  project
allowHeadlessExecution: (BOOL allowHeadlessExecution
restorationEnabled: (BOOL restorationEnabled 
implementation

Reimplemented in FlutterHeadlessDartRunner.

Definition at line 157 of file FlutterEngine.mm.

181 :(NSString*)labelPrefix
183 allowHeadlessExecution:(BOOL)allowHeadlessExecution
184 restorationEnabled:(BOOL)restorationEnabled {
185 self = [super init];
186 NSAssert(self, @"Super init cannot be nil");
187 NSAssert(labelPrefix, @"labelPrefix is required");
188
189 _restorationEnabled = restorationEnabled;
190 _allowHeadlessExecution = allowHeadlessExecution;
191 _labelPrefix = [labelPrefix copy];
192
193 _weakFactory = std::make_unique<fml::WeakNSObjectFactory<FlutterEngine>>(self);
194
195 if (project == nil) {
196 _dartProject.reset([[FlutterDartProject alloc] init]);
197 } else {
198 _dartProject.reset([project retain]);
199 }
200
201 _enableEmbedderAPI = _dartProject.get().settings.enable_embedder_api;
202 if (_enableEmbedderAPI) {
203 NSLog(@"============== iOS: enable_embedder_api is on ==============");
204 _embedderAPI.struct_size = sizeof(FlutterEngineProcTable);
205 FlutterEngineGetProcAddresses(&_embedderAPI);
206 }
207
208 if (!EnableTracingIfNecessary([_dartProject.get() settings])) {
209 NSLog(
210 @"Cannot create a FlutterEngine instance in debug mode without Flutter tooling or "
211 @"Xcode.\n\nTo launch in debug mode in iOS 14+, run flutter run from Flutter tools, run "
212 @"from an IDE with a Flutter IDE plugin or run the iOS project from Xcode.\nAlternatively "
213 @"profile and release mode apps can be launched from the home screen.");
214 [self release];
215 return nil;
216 }
217
218 _pluginPublications = [[NSMutableDictionary alloc] init];
219 _registrars = [[NSMutableDictionary alloc] init];
220 [self recreatePlatformViewController];
221
222 _binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self];
223 _textureRegistry = [[FlutterTextureRegistryRelay alloc] initWithParent:self];
225
226 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
227 [center addObserver:self
228 selector:@selector(onMemoryWarning:)
229 name:UIApplicationDidReceiveMemoryWarningNotification
230 object:nil];
231
232#if APPLICATION_EXTENSION_API_ONLY
233 if (@available(iOS 13.0, *)) {
234 [self setUpSceneLifecycleNotifications:center];
235 } else {
236 [self setUpApplicationLifecycleNotifications:center];
237 }
238#else
239 [self setUpApplicationLifecycleNotifications:center];
240#endif
241
242 [center addObserver:self
243 selector:@selector(onLocaleUpdated:)
244 name:NSCurrentLocaleDidChangeNotification
245 object:nil];
246
247 return self;
248}
Maintains a current integer assigned to a name (connections).
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
Definition: embedder.cc:3335
instancetype init()
BOOL _restorationEnabled
BOOL _allowHeadlessExecution
NSString * _labelPrefix
bool EnableTracingIfNecessary(const Settings &vm_settings)
Enables tracing in the process so that JIT mode VMs may be launched. Explicitly enabling tracing is n...
Definition: ptrace_check.h:45
Function-pointer-based versions of the APIs above.
Definition: embedder.h:3319

◆ initWithName:project:allowHeadlessExecution:restorationEnabled: [2/2]

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

Initialize this FlutterEngine with a FlutterDartProject.

If the FlutterDartProject is not specified, the FlutterEngine will attempt to locate the project in a default location (the flutter_assets folder in the iOS application bundle).

A newly initialized engine will not run the FlutterDartProject until either -runWithEntrypoint: or -runWithEntrypoint:libraryURI: is called.

Parameters
labelPrefixThe label prefix used to identify threads for this instance. Should be unique across FlutterEngine instances, and is used in instrumentation to label the threads used by this FlutterEngine.
projectThe FlutterDartProject to run.
allowHeadlessExecutionWhether or not to allow this instance to continue running after passing a nil FlutterViewController to -setViewController:.
restorationEnabledWhether state restoration is enabled. When true, the framework will wait for the attached view controller to provide restoration data.

◆ initWithScenario:withCompletion:

- (instancetype) initWithScenario: (NSString*)  scenario
withCompletion: (nullable void(^)(void))  engineRunCompletion 

Provided by category FlutterEngine(ScenariosTest).

Definition at line 1 of file FlutterEngine+ScenariosTest.m.

9 :(NSString*)scenario
10 withCompletion:(nullable void (^)(void))engineRunCompletion {
11 NSAssert([scenario length] != 0, @"You need to provide a scenario");
12 self = [self initWithName:[NSString stringWithFormat:@"Test engine for %@", scenario]
13 project:nil];
14 [self run];
15
16 [self.binaryMessenger setMessageHandlerOnChannel:@"waiting_for_status"
17 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
19 methodChannelWithName:@"driver"
20 binaryMessenger:self.binaryMessenger
22 [channel invokeMethod:@"set_scenario"
23 arguments:@{@"name" : scenario}];
24
25 if (engineRunCompletion != nil) {
26 engineRunCompletion();
27 }
28 }];
29 return self;
30}
size_t length

◆ iosPlatformView

- (PlatformViewIOS *) FlutterEngine:
implementation

Definition at line 157 of file FlutterEngine.mm.

354 {
356 return static_cast<flutter::PlatformViewIOS*>(_shell->GetPlatformView().get());
357}
#define FML_DCHECK(condition)
Definition: logging.h:103

◆ isProfilerEnabled

+ (BOOL) isProfilerEnabled
implementation

Definition at line 157 of file FlutterEngine.mm.

775 {
776 bool profilerEnabled = false;
777#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \
778 (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE)
779 profilerEnabled = true;
780#endif
781 return profilerEnabled;
782}

◆ isUsingImpeller

- (BOOL) isUsingImpeller
implementation

Reimplemented from <FlutterViewEngineDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1491 {
1492 return self.project.isImpellerEnabled;
1493}

◆ launchEngine:libraryURI:entrypointArgs:

- (void) launchEngine: (NSString*)  entrypoint
libraryURI: (NSString*)  libraryOrNil
entrypointArgs: (NSArray<NSString*>*)  entrypointArgs 
implementation

Definition at line 157 of file FlutterEngine.mm.

753 :(NSString*)entrypoint
754 libraryURI:(NSString*)libraryOrNil
755 entrypointArgs:(NSArray<NSString*>*)entrypointArgs {
756 // Launch the Dart application with the inferred run configuration.
757 self.shell.RunEngine([_dartProject.get() runConfigurationForEntrypoint:entrypoint
758 libraryOrNil:libraryOrNil
759 entrypointArgs:entrypointArgs]);
760}

◆ loadAOTData:

- (void) loadAOTData: (NSString *)  assetsDir
implementation

Loads the AOT snapshots and instructions from the elf bundle (app_elf_snapshot.so) into _aotData, if it is present in the assets directory.

Definition at line 484 of file FlutterEngine.mm.

706 :(NSString*)assetsDir {
707 if (!_embedderAPI.RunsAOTCompiledDartCode()) {
708 return;
709 }
710
711 BOOL isDirOut = false; // required for NSFileManager fileExistsAtPath.
712 NSFileManager* fileManager = [NSFileManager defaultManager];
713
714 // This is the location where the test fixture places the snapshot file.
715 // For applications built by Flutter tool, this is in "App.framework".
716 NSString* elfPath = [NSString pathWithComponents:@[ assetsDir, @"app_elf_snapshot.so" ]];
717
718 if (![fileManager fileExistsAtPath:elfPath isDirectory:&isDirOut]) {
719 return;
720 }
721
724 source.elf_path = [elfPath cStringUsingEncoding:NSUTF8StringEncoding];
725
726 auto result = _embedderAPI.CreateAOTData(&source, &_aotData);
727 if (result != kSuccess) {
728 NSLog(@"Failed to load AOT data from: %@", elfPath);
729 }
730}
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition: embedder.h:2110
SkBitmap source
Definition: examples.cpp:28
_FlutterEngineAOTData * _aotData

◆ lookupKeyForAsset:

- (NSString *) lookupKeyForAsset: (NSString*)  asset
implementation

Definition at line 822 of file FlutterEngine.mm.

1323 :(NSString*)asset {
1325}
NSString * lookupKeyForAsset:(NSString *asset)

◆ lookupKeyForAsset:fromPackage:

- (NSString *) lookupKeyForAsset: (NSString*)  asset
fromPackage: (NSString*)  package 
implementation

Definition at line 822 of file FlutterEngine.mm.

1327 :(NSString*)asset fromPackage:(NSString*)package {
1328 return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package];
1329}

◆ macOSCompositor

- (FlutterCompositor *) FlutterEngine:
implementation

The FlutterCompositor object currently in use by the FlutterEngine.

May be nil if the compositor has not been initialized yet.

Provided by category FlutterEngine(Test).

Definition at line 484 of file FlutterEngine.mm.

1547 {
1548 return _macOSCompositor.get();
1549}

◆ makeBackgroundTaskQueue

- (NSObject< FlutterTaskQueue > *) makeBackgroundTaskQueue
implementation

TODO(gaaclarke): Remove optional when macos supports Background Platform Channels.

Reimplemented from <FlutterBinaryMessenger>.

Definition at line 822 of file FlutterEngine.mm.

1271 {
1273}
static NSObject< FlutterTaskQueue > * MakeBackgroundTaskQueue()

◆ makeThreadHost:

+ (ThreadHost) FlutterEngine: (NSString*)  threadLabel
implementation

Definition at line 157 of file FlutterEngine.mm.

789 :(NSString*)threadLabel {
790 // The current thread will be used as the platform thread. Ensure that the message loop is
791 // initialized.
793
794 uint32_t threadHostType = flutter::ThreadHost::Type::kUi | flutter::ThreadHost::Type::kRaster |
795 flutter::ThreadHost::Type::kIo;
796
798 threadHostType = threadHostType | flutter::ThreadHost::Type::kProfiler;
799 }
800
801 flutter::ThreadHost::ThreadHostConfig host_config(threadLabel.UTF8String, threadHostType,
803
804 host_config.ui_config =
806 flutter::ThreadHost::Type::kUi, threadLabel.UTF8String),
808
809 host_config.raster_config =
811 flutter::ThreadHost::Type::kRaster, threadLabel.UTF8String),
813
814 host_config.io_config =
816 flutter::ThreadHost::Type::kIo, threadLabel.UTF8String),
818
819 return (flutter::ThreadHost){host_config};
820}
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
@ kDisplay
Suitable for threads which generate data for the display.
@ kRaster
Suitable for thread which raster data.
Definition: embedder.h:266
static void IOSPlatformThreadConfigSetter(const fml::Thread::ThreadConfig &config)
fml::Thread::ThreadConfig ThreadConfig
Definition: thread_host.h:17
static std::string MakeThreadName(Type type, const std::string &prefix)
Use the prefix and thread type to generator a thread name.
Definition: thread_host.cc:15
The collection of all the threads used by the engine.
Definition: thread_host.h:21

◆ markTextureFrameAvailable:

- (BOOL) markTextureFrameAvailable: (int64_t)  textureID
implementation

Marks texture with the given id as available. Returns YES on success.

Definition at line 484 of file FlutterEngine.mm.

1507 :(int64_t)textureID {
1508 return _embedderAPI.MarkExternalTextureFrameAvailable(_engine, textureID) == kSuccess;
1509}

◆ maybeSetupPlatformViewChannels

- (void) maybeSetupPlatformViewChannels
implementation

Definition at line 157 of file FlutterEngine.mm.

714 {
715 if (_shell && self.shell.IsSetup()) {
717 [_platformChannel.get() setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
718 [platformPlugin handleMethodCall:call result:result];
719 }];
720
721 fml::WeakNSObject<FlutterEngine> weakSelf = [self getWeakNSObject];
722 [_platformViewsChannel.get()
723 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
724 if (weakSelf) {
725 weakSelf.get().platformViewsController->OnMethodCall(call, result);
726 }
727 }];
728
730 [_textInputChannel.get() setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
731 [textInputPlugin handleMethodCall:call result:result];
732 }];
733
735 [_undoManagerChannel.get()
736 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
737 [undoManagerPlugin handleMethodCall:call result:result];
738 }];
739
740 FlutterSpellCheckPlugin* spellCheckPlugin = _spellCheckPlugin.get();
741 [_spellCheckChannel.get()
742 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
743 [spellCheckPlugin handleMethodCall:call result:result];
744 }];
745 }
746}
bool IsSetup() const
Used by embedders to check if all shell subcomponents are initialized. It is the embedder's responsib...
Definition: shell.cc:728
FlutterUndoManagerPlugin * undoManagerPlugin()
FlutterPlatformPlugin * platformPlugin()
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
fml::scoped_nsobject< FlutterSpellCheckPlugin > _spellCheckPlugin
fml::scoped_nsobject< FlutterPlatformPlugin > _platformPlugin
fml::scoped_nsobject< FlutterUndoManagerPlugin > _undoManagerPlugin
fml::scoped_nsobject< FlutterTextInputPlugin > _textInputPlugin

◆ notifyLowMemory

- (void) notifyLowMemory
implementation

Reimplemented in FlutterEnginePartialMock.

Provided by category FlutterEngine(TestLowMemory).

Definition at line 822 of file FlutterEngine.mm.

977 {
978 if (_shell) {
979 _shell->NotifyLowMemoryWarning();
980 }
981 [_systemChannel sendMessage:@{@"type" : @"memoryPressure"}];
982}

◆ notifyViewControllerDeallocated

- (void) notifyViewControllerDeallocated
implementation

Definition at line 157 of file FlutterEngine.mm.

464 {
465 [[self lifecycleChannel] sendMessage:@"AppLifecycleState.detached"];
466 _textInputPlugin.get().viewController = nil;
468 [self destroyContext];
469 } else if (_shell) {
470 flutter::PlatformViewIOS* platform_view = [self iosPlatformView];
471 if (platform_view) {
472 platform_view->SetOwnerViewController({});
473 }
474 }
475 [_textInputPlugin.get() resetViewResponder];
476 _viewController.reset();
477}
std::unique_ptr< flutter::PlatformViewIOS > platform_view
fml::WeakNSObject< FlutterViewController > _viewController

◆ NS_UNAVAILABLE

- (nonnull instancetype) NS_UNAVAILABLE

◆ observatoryUrl

- (NSURL *) observatoryUrl
implementation

Definition at line 157 of file FlutterEngine.mm.

547 {
548 return [_publisher.get() url];
549}

◆ onAccessibilityStatusChanged:

- (void) onAccessibilityStatusChanged: (NSNotification*)  notification
implementation

Definition at line 484 of file FlutterEngine.mm.

1235 :(NSNotification*)notification {
1236 BOOL enabled = [notification.userInfo[kEnhancedUserInterfaceKey] boolValue];
1237 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1238 FlutterViewController* nextViewController;
1239 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1240 [nextViewController onAccessibilityStatusChanged:enabled];
1241 }
1242
1243 self.semanticsEnabled = enabled;
1244}
void onAccessibilityStatusChanged:(NSNotification *notification)

◆ onLocaleUpdated:

- (void) onLocaleUpdated: (NSNotification*)  notification
implementation

Definition at line 822 of file FlutterEngine.mm.

1397 :(NSNotification*)notification {
1398 // Get and pass the user's preferred locale list to dart:ui.
1399 NSMutableArray<NSString*>* localeData = [[[NSMutableArray alloc] init] autorelease];
1400 NSArray<NSString*>* preferredLocales = [NSLocale preferredLanguages];
1401 for (NSString* localeID in preferredLocales) {
1402 NSLocale* locale = [[[NSLocale alloc] initWithLocaleIdentifier:localeID] autorelease];
1403 NSString* languageCode = [locale objectForKey:NSLocaleLanguageCode];
1404 NSString* countryCode = [locale objectForKey:NSLocaleCountryCode];
1405 NSString* scriptCode = [locale objectForKey:NSLocaleScriptCode];
1406 NSString* variantCode = [locale objectForKey:NSLocaleVariantCode];
1407 if (!languageCode) {
1408 continue;
1409 }
1410 [localeData addObject:languageCode];
1411 [localeData addObject:(countryCode ? countryCode : @"")];
1412 [localeData addObject:(scriptCode ? scriptCode : @"")];
1413 [localeData addObject:(variantCode ? variantCode : @"")];
1414 }
1415 if (localeData.count == 0) {
1416 return;
1417 }
1418 [self.localizationChannel invokeMethod:@"setLocale" arguments:localeData];
1419}

◆ onMemoryWarning:

- (void) onMemoryWarning: (NSNotification*)  notification
implementation

Definition at line 822 of file FlutterEngine.mm.

1383 :(NSNotification*)notification {
1384 [self notifyLowMemory];
1385}

◆ onSettingsChanged:

- (void) onSettingsChanged: (NSNotification*)  notification
implementation

Definition at line 484 of file FlutterEngine.mm.

955 :(NSNotification*)notification {
956 // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/32015.
957 NSString* brightness =
958 [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
959 [_settingsChannel sendMessage:@{
960 @"platformBrightness" : [brightness isEqualToString:@"Dark"] ? @"dark" : @"light",
961 // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/32006.
962 @"textScaleFactor" : @1.0,
963 @"alwaysUse24HourFormat" : @false
964 }];
965}

◆ onVSync:

- (void) onVSync: (uintptr_t)  baton
implementation

Definition at line 484 of file FlutterEngine.mm.

1118 :(uintptr_t)baton {
1119 @synchronized(_vsyncWaiters) {
1120 // TODO(knopp): Use vsync waiter for correct view.
1121 // https://github.com/flutter/flutter/issues/142845
1122 FlutterVSyncWaiter* waiter = [_vsyncWaiters objectForKey:@(kFlutterImplicitViewId)];
1123 [waiter waitForVSync:baton];
1124 }
1125}
void waitForVSync:(uintptr_t baton)

◆ platformPlugin

- (FlutterPlatformPlugin *) platformPlugin
implementation

Definition at line 157 of file FlutterEngine.mm.

495 {
496 return _platformPlugin.get();
497}

◆ platformTaskRunner

- (RefPtr<) fml:
implementation

Definition at line 157 of file FlutterEngine.mm.

359 {
361 return _shell->GetTaskRunners().GetPlatformTaskRunner();
362}

◆ platformView

- (WeakPtr<) flutter:
implementation

Definition at line 157 of file FlutterEngine.mm.

349 {
351 return _shell->GetPlatformView();
352}

◆ platformViewController

- (FlutterPlatformViewController *) platformViewController
implementation

Definition at line 484 of file FlutterEngine.mm.

1042 {
1044}

◆ platformViewsController

- (shared_ptr<) flutter:
implementation

Reimplemented from <FlutterViewEngineDelegate>.

Definition at line 157 of file FlutterEngine.mm.

498 {
500}

◆ platformViewsRenderingAPI

- (IOSRenderingAPI) FlutterEngine:
implementation

Provided by category FlutterEngine(Test).

Definition at line 157 of file FlutterEngine.mm.

277 {
278 return _renderingApi;
279}
flutter::IOSRenderingAPI _renderingApi

◆ playSystemSound:

- (void) playSystemSound: (NSString*)  soundType
implementation

Definition at line 484 of file FlutterEngine.mm.

1304 :(NSString*)soundType {
1305 if ([soundType isEqualToString:@"SystemSoundType.alert"]) {
1306 NSBeep();
1307 }
1308}

◆ pluginRegistry

- (id< FlutterPluginRegistry >) pluginRegistry
implementation

Definition at line 822 of file FlutterEngine.mm.

1331 {
1332 return self;
1333}

◆ postMainThreadTask:targetTimeInNanoseconds:

- (void) postMainThreadTask: (FlutterTask task
targetTimeInNanoseconds: (uint64_t)  targetTime 
implementation

Requests that the task be posted back the to the Flutter engine at the target time. The target time is in the clock used by the Flutter engine.

Definition at line 484 of file FlutterEngine.mm.

1530 :(FlutterTask)task targetTimeInNanoseconds:(uint64_t)targetTime {
1531 __weak FlutterEngine* weakSelf = self;
1532 auto worker = ^{
1533 [weakSelf runTaskOnEmbedder:task];
1534 };
1535
1536 const auto engine_time = _embedderAPI.GetCurrentTime();
1537 if (targetTime <= engine_time) {
1538 dispatch_async(dispatch_get_main_queue(), worker);
1539
1540 } else {
1541 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, targetTime - engine_time),
1542 dispatch_get_main_queue(), worker);
1543 }
1544}

◆ project

- (FlutterDartProject *) project
implementation

Definition at line 822 of file FlutterEngine.mm.

1487 {
1488 return _dartProject.get();
1489}

◆ rasterTaskRunner

- (RefPtr<) fml:
implementation

Definition at line 157 of file FlutterEngine.mm.

369 {
371 return _shell->GetTaskRunners().GetRasterTaskRunner();
372}

◆ recreatePlatformViewController

- (void) recreatePlatformViewController
implementation

◆ registerTexture: [1/2]

- (int64_t) registerTexture: (id<FlutterTexture>)  texture
implementation

Definition at line 484 of file FlutterEngine.mm.

1495 :(id<FlutterTexture>)texture {
1496 return [_renderer registerTexture:texture];
1497}
FlTexture * texture

◆ registerTexture: [2/2]

- (int64_t) registerTexture: (NSObject< FlutterTexture > *)  texture
implementation

Registers a FlutterTexture for usage in Flutter and returns an id that can be used to reference that texture when calling into Flutter with channels. Textures must be registered on the platform thread. On success returns the pointer to the registered texture, else returns 0.

Reimplemented from <FlutterTextureRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1309 :(NSObject<FlutterTexture>*)texture {
1310 int64_t textureId = _nextTextureId++;
1311 self.iosPlatformView->RegisterExternalTexture(textureId, texture);
1312 return textureId;
1313}
int64_t _nextTextureId

◆ registerTextureWithID:

- (BOOL) registerTextureWithID: (int64_t)  textureId
implementation

Registers an external texture with the given id. Returns YES on success.

Definition at line 484 of file FlutterEngine.mm.

1499 :(int64_t)textureId {
1500 return _embedderAPI.RegisterExternalTexture(_engine, textureId) == kSuccess;
1501}

◆ registerViewController:forIdentifier:

- (void) registerViewController: (FlutterViewController *)  controller
forIdentifier: (FlutterViewIdentifier viewIdentifier 
implementation

An internal method that adds the view controller with the given ID.

This method assigns the controller with the ID, puts the controller into the map, and does assertions related to the implicit view ID.

Definition at line 484 of file FlutterEngine.mm.

732 :(FlutterViewController*)controller
733 forIdentifier:(FlutterViewIdentifier)viewIdentifier {
734 NSAssert(controller != nil, @"The controller must not be nil.");
735 NSAssert(controller.engine == nil,
736 @"The FlutterViewController is unexpectedly attached to "
737 @"engine %@ before initialization.",
738 controller.engine);
739 NSAssert([_viewControllers objectForKey:@(viewIdentifier)] == nil,
740 @"The requested view ID is occupied.");
741 [_viewControllers setObject:controller forKey:@(viewIdentifier)];
742 [controller setUpWithEngine:self
743 viewIdentifier:viewIdentifier
744 threadSynchronizer:_threadSynchronizer];
745 NSAssert(controller.viewIdentifier == viewIdentifier, @"Failed to assign view ID.");
746 // Verify that the controller's property are updated accordingly. Failing the
747 // assertions is likely because either the FlutterViewController or the
748 // FlutterEngine is mocked. Please subclass these classes instead.
749 NSAssert(controller.attached, @"The FlutterViewController should switch to the attached mode "
750 @"after it is added to a FlutterEngine.");
751 NSAssert(controller.engine == self,
752 @"The FlutterViewController was added to %@, but its engine unexpectedly became %@.",
753 self, controller.engine);
754
755 if (controller.viewLoaded) {
756 [self viewControllerViewDidLoad:controller];
757 }
758}
FlutterViewIdentifier viewIdentifier
void setUpWithEngine:viewIdentifier:threadSynchronizer:(FlutterEngine *engine, [viewIdentifier] FlutterViewIdentifier viewIdentifier, [threadSynchronizer] FlutterThreadSynchronizer *threadSynchronizer)
NSMapTable * _viewControllers

◆ registrarForPlugin:

- (id< FlutterPluginRegistrar >) registrarForPlugin: (NSString *)  pluginKey
implementation

Returns a registrar for registering a plugin.

Parameters
pluginKeyThe unique key identifying the plugin.

Reimplemented from <FlutterPluginRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1337 :(NSString*)pluginKey {
1338 NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey);
1339 self.pluginPublications[pluginKey] = [NSNull null];
1340 FlutterEngineRegistrar* result = [[FlutterEngineRegistrar alloc] initWithPlugin:pluginKey
1341 flutterEngine:self];
1342 self.registrars[pluginKey] = result;
1343 return [result autorelease];
1344}
NSMutableDictionary * pluginPublications

◆ removeViewController:

- (void) removeViewController: (nonnull FlutterViewController*)  viewController
implementation

Definition at line 484 of file FlutterEngine.mm.

900 [self deregisterViewControllerForIdentifier:viewController.viewIdentifier];
901 [self shutDownIfNeeded];
902}

◆ resetChannels

- (void) resetChannels
implementation

Definition at line 157 of file FlutterEngine.mm.

555 {
564 _lifecycleChannel.reset();
565 _systemChannel.reset();
566 _settingsChannel.reset();
567 _keyEventChannel.reset();
569}
void reset(NST *object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
fml::scoped_nsobject< FlutterMethodChannel > _undoManagerChannel
fml::scoped_nsobject< FlutterBasicMessageChannel > _lifecycleChannel
fml::scoped_nsobject< FlutterMethodChannel > _localizationChannel
fml::scoped_nsobject< FlutterMethodChannel > _navigationChannel
fml::scoped_nsobject< FlutterMethodChannel > _spellCheckChannel
fml::scoped_nsobject< FlutterMethodChannel > _platformViewsChannel
fml::scoped_nsobject< FlutterMethodChannel > _scribbleChannel
fml::scoped_nsobject< FlutterBasicMessageChannel > _keyEventChannel
fml::scoped_nsobject< FlutterBasicMessageChannel > _systemChannel
fml::scoped_nsobject< FlutterMethodChannel > _restorationChannel
fml::scoped_nsobject< FlutterMethodChannel > _textInputChannel

◆ restorationPlugin

- (FlutterRestorationPlugin *) restorationPlugin
implementation

Definition at line 157 of file FlutterEngine.mm.

507 {
508 return _restorationPlugin.get();
509}
fml::scoped_nsobject< FlutterRestorationPlugin > _restorationPlugin

◆ run

- (BOOL) run

Runs a Dart program on an Isolate from the main Dart library (i.e. the library that contains main()), using main() as the entrypoint (the default for Flutter projects), and using "/" (the default route) as the initial route.

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

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

Definition at line 822 of file FlutterEngine.mm.

937 {
938 return [self runWithEntrypoint:FlutterDefaultDartEntrypoint
939 libraryURI:nil
940 initialRoute:FlutterDefaultInitialRoute];
941}

◆ running

- (BOOL) running
implementation

True if the engine is currently running.

Definition at line 484 of file FlutterEngine.mm.

904 {
905 return _engine != nullptr;
906}

◆ runTaskOnEmbedder:

- (void) runTaskOnEmbedder: (FlutterTask task
implementation

Definition at line 484 of file FlutterEngine.mm.

1521 :(FlutterTask)task {
1522 if (_engine) {
1523 auto result = _embedderAPI.RunTask(_engine, &task);
1524 if (result != kSuccess) {
1525 NSLog(@"Could not post a task to the Flutter engine.");
1526 }
1527 }
1528}

◆ runWithEntrypoint: [1/3]

- (BOOL) runWithEntrypoint: (NSString*)  entrypoint
implementation

Definition at line 822 of file FlutterEngine.mm.

949 :(NSString*)entrypoint {
950 return [self runWithEntrypoint:entrypoint libraryURI:nil initialRoute:FlutterDefaultInitialRoute];
951}

◆ runWithEntrypoint: [2/3]

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

Runs a Dart program on an Isolate from the main Dart library (i.e. the library that contains main()), using "/" (the default route) as the initial route.

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

Parameters
entrypointThe name of a top-level function from the same Dart library that contains the app's main() function. If this is FlutterDefaultDartEntrypoint (or 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.

◆ runWithEntrypoint: [3/3]

- (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
entrypointThe 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.

◆ runWithEntrypoint:initialRoute: [1/2]

- (BOOL) runWithEntrypoint: (NSString*)  entrypoint
initialRoute: (NSString*)  initialRoute 
implementation

Definition at line 822 of file FlutterEngine.mm.

953 :(NSString*)entrypoint initialRoute:(NSString*)initialRoute {
954 return [self runWithEntrypoint:entrypoint libraryURI:nil initialRoute:initialRoute];
955}

◆ runWithEntrypoint:initialRoute: [2/2]

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

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 and have no effect.

Parameters
entrypointThe name of a top-level function from the same Dart library that contains the app's main() function. If this is FlutterDefaultDartEntrypoint (or 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.
initialRouteThe name of the initial Flutter Navigator Route to load. If this is FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
Returns
YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.

◆ runWithEntrypoint:libraryURI: [1/2]

- (BOOL) runWithEntrypoint: (NSString*)  entrypoint
libraryURI: (NSString*)  libraryURI 
implementation

Definition at line 822 of file FlutterEngine.mm.

943 :(NSString*)entrypoint libraryURI:(NSString*)libraryURI {
944 return [self runWithEntrypoint:entrypoint
945 libraryURI:libraryURI
946 initialRoute:FlutterDefaultInitialRoute];
947}

◆ runWithEntrypoint:libraryURI: [2/2]

- (BOOL) runWithEntrypoint: (nullable NSString *)  entrypoint
libraryURI: (nullable NSString *)  uri 

Runs a Dart program on an Isolate using the specified entrypoint and Dart library, which may not be the same as the library containing the Dart program's main() function.

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

Parameters
entrypointThe name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint (or nil); this 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.
uriThe URI of the Dart library which contains the entrypoint method (example "package:foo_package/main.dart"). If nil, this will default to the same library as the main() function in the Dart program.
Returns
YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.

◆ runWithEntrypoint:libraryURI:initialRoute: [1/2]

- (BOOL) runWithEntrypoint: (NSString*)  entrypoint
libraryURI: (NSString*)  libraryURI
initialRoute: (NSString*)  initialRoute 
implementation

Definition at line 822 of file FlutterEngine.mm.

957 :(NSString*)entrypoint
958 libraryURI:(NSString*)libraryURI
959 initialRoute:(NSString*)initialRoute {
960 return [self runWithEntrypoint:entrypoint
961 libraryURI:libraryURI
962 initialRoute:initialRoute
963 entrypointArgs:nil];
964}

◆ runWithEntrypoint:libraryURI:initialRoute: [2/2]

- (BOOL) runWithEntrypoint: (nullable NSString *)  entrypoint
libraryURI: (nullable NSString *)  libraryURI
initialRoute: (nullable NSString *)  initialRoute 

Runs a Dart program on an Isolate using the specified entrypoint and Dart library, which may not be the same as the library containing the Dart program's main() function.

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

Parameters
entrypointThe name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint (or nil); this 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.
libraryURIThe URI of the Dart library which contains the entrypoint method (example "package:foo_package/main.dart"). If nil, this will default to the same library as the main() function in the Dart program.
initialRouteThe name of the initial Flutter Navigator Route to load. If this is FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
Returns
YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.

◆ runWithEntrypoint:libraryURI:initialRoute:entrypointArgs: [1/2]

- (BOOL) runWithEntrypoint: (NSString*)  entrypoint
libraryURI: (NSString*)  libraryURI
initialRoute: (NSString*)  initialRoute
entrypointArgs: (NSArray<NSString*>*)  entrypointArgs 
implementation

Definition at line 822 of file FlutterEngine.mm.

966 :(NSString*)entrypoint
967 libraryURI:(NSString*)libraryURI
968 initialRoute:(NSString*)initialRoute
969 entrypointArgs:(NSArray<NSString*>*)entrypointArgs {
970 if ([self createShell:entrypoint libraryURI:libraryURI initialRoute:initialRoute]) {
971 [self launchEngine:entrypoint libraryURI:libraryURI entrypointArgs:entrypointArgs];
972 }
973
974 return _shell != nullptr;
975}

◆ runWithEntrypoint:libraryURI:initialRoute:entrypointArgs: [2/2]

- (BOOL) runWithEntrypoint: (nullable NSString *)  entrypoint
libraryURI: (nullable NSString *)  libraryURI
initialRoute: (nullable NSString *)  initialRoute
entrypointArgs: (nullable NSArray< NSString * > *)  entrypointArgs 

Runs a Dart program on an Isolate using the specified entrypoint and Dart library, which may not be the same as the library containing the Dart program's main() function.

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

Parameters
entrypointThe name of a top-level function from a Dart library. If this is FlutterDefaultDartEntrypoint (or nil); this 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.
libraryURIThe URI of the Dart library which contains the entrypoint method (example "package:foo_package/main.dart"). If nil, this will default to the same library as the main() function in the Dart program.
initialRouteThe name of the initial Flutter Navigator Route to load. If this is FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
entrypointArgsArguments passed as a list of string to Dart's entrypoint function.
Returns
YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.

◆ sceneDidEnterBackground:

- (void) sceneDidEnterBackground: (ios(13.0))  API_AVAILABLE

Provided by category FlutterEngine(Test).

◆ sceneWillEnterForeground:

- (void) sceneWillEnterForeground: (ios(13.0))  API_AVAILABLE

Provided by category FlutterEngine(Test).

◆ screens

- (NSArray< NSScreen * > *) screens
implementation

Returns an array of screen objects representing all of the screens available on the system.

Reimplemented in MockableFlutterEngine.

Definition at line 484 of file FlutterEngine.mm.

912 {
913 return [NSScreen screens];
914}

◆ screenshot:base64Encode:

- Rasterizer: (flutter::Rasterizer::ScreenshotType type
base64Encode: (bool)  base64Encode 
implementation

Definition at line 157 of file FlutterEngine.mm.

749 base64Encode:(bool)base64Encode {
750 return self.shell.Screenshot(type, base64Encode);
751}
ScreenshotType
The type of the screenshot to obtain of the previously rendered layer tree.
Definition: rasterizer.h:347

◆ scribbleChannel

- (FlutterMethodChannel *) scribbleChannel
implementation

Definition at line 157 of file FlutterEngine.mm.

528 {
529 return _scribbleChannel.get();
530}
T get() const __attribute((ns_returns_not_retained))

◆ sendInitialSettings

- (void) sendInitialSettings
implementation

Definition at line 484 of file FlutterEngine.mm.

967 {
968 // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/32015.
969 [[NSDistributedNotificationCenter defaultCenter]
970 addObserver:self
971 selector:@selector(onSettingsChanged:)
972 name:@"AppleInterfaceThemeChangedNotification"
973 object:nil];
974 [self onSettingsChanged:nil];
975}

◆ sendKeyEvent:callback:userData: [1/2]

- (void) sendKeyEvent: (const FlutterKeyEvent&)  event
callback: (FlutterKeyEventCallback callback
userData: (ios(13.4))  API_AVAILABLE 
implementation

Definition at line 157 of file FlutterEngine.mm.

374 :(const FlutterKeyEvent&)event
376 userData:(void*)userData API_AVAILABLE(ios(13.4)) {
377 if (@available(iOS 13.4, *)) {
378 } else {
379 return;
380 }
381 if (!self.platformView) {
382 return;
383 }
384 const char* character = event.character;
385
386 flutter::KeyData key_data;
387 key_data.Clear();
388 key_data.timestamp = (uint64_t)event.timestamp;
389 switch (event.type) {
392 break;
395 break;
398 break;
399 }
400 key_data.physical = event.physical;
401 key_data.logical = event.logical;
402 key_data.synthesized = event.synthesized;
403
404 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data, character);
405 NSData* message = [NSData dataWithBytes:packet->data().data() length:packet->data().size()];
406
407 auto response = ^(NSData* reply) {
408 if (callback == nullptr) {
409 return;
410 }
411 BOOL handled = FALSE;
412 if (reply.length == 1 && *reinterpret_cast<const uint8_t*>(reply.bytes) == 1) {
413 handled = TRUE;
414 }
415 callback(handled, userData);
416 };
417
418 [self sendOnChannel:kFlutterKeyDataChannel message:message binaryReply:response];
419}
void(* FlutterKeyEventCallback)(bool, void *)
Definition: embedder.h:1155
@ kFlutterKeyEventTypeDown
Definition: embedder.h:1076
@ kFlutterKeyEventTypeUp
Definition: embedder.h:1075
@ kFlutterKeyEventTypeRepeat
Definition: embedder.h:1077
FlKeyEvent * event
switch(prop_id)
return FALSE
SK_API sk_sp< SkSurface > ios(9.0)
API_AVAILABLE(ios(14.0), macos(11.0)) static NSString *MTLCommandEncoderErrorStateToString(MTLCommandEncoderErrorState state)
uint64_t synthesized
Definition: key_data.h:70
uint64_t logical
Definition: key_data.h:66
uint64_t physical
Definition: key_data.h:65
KeyEventType type
Definition: key_data.h:64
uint64_t timestamp
Definition: key_data.h:63

◆ sendKeyEvent:callback:userData: [2/2]

- (void) sendKeyEvent: (const FlutterKeyEvent&)  event
callback: (FlutterKeyEventCallback callback
userData: (void*)  userData 
implementation

Definition at line 484 of file FlutterEngine.mm.

1014 :(const FlutterKeyEvent&)event
1016 userData:(void*)userData {
1017 _embedderAPI.SendKeyEvent(_engine, &event, callback, userData);
1018}

◆ sendOnChannel:message: [1/2]

- (void) sendOnChannel: (nonnull NSString*)  channel
message: (nullable NSData*)  message 
implementation

Definition at line 484 of file FlutterEngine.mm.

1394 :(nonnull NSString*)channel message:(nullable NSData*)message {
1395 [self sendOnChannel:channel message:message binaryReply:nil];
1396}

◆ sendOnChannel:message: [2/2]

- (void) sendOnChannel: (NSString*)  channel
message: (NSData*)  message 
implementation

Definition at line 822 of file FlutterEngine.mm.

1244 :(NSString*)channel message:(NSData*)message {
1245 [self sendOnChannel:channel message:message binaryReply:nil];
1246}

◆ sendOnChannel:message:binaryReply: [1/2]

- (void) sendOnChannel: (NSString *)  channel
message: (NSData *_Nullable)  message
binaryReply: (FlutterBinaryReply _Nullable)  callback 
implementation

Sends a binary message to the Flutter side on the specified channel, expecting an asynchronous reply.

Parameters
channelThe channel name.
messageThe message.
callbackA callback for receiving a reply.

Reimplemented from <FlutterBinaryMessenger>.

Definition at line 484 of file FlutterEngine.mm.

1398 :(NSString*)channel
1399 message:(NSData* _Nullable)message
1400 binaryReply:(FlutterBinaryReply _Nullable)callback {
1401 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1402 if (callback) {
1403 struct Captures {
1404 FlutterBinaryReply reply;
1405 };
1406 auto captures = std::make_unique<Captures>();
1407 captures->reply = callback;
1408 auto message_reply = [](const uint8_t* data, size_t data_size, void* user_data) {
1409 auto captures = reinterpret_cast<Captures*>(user_data);
1410 NSData* reply_data = nil;
1411 if (data != nullptr && data_size > 0) {
1412 reply_data = [NSData dataWithBytes:static_cast<const void*>(data) length:data_size];
1413 }
1414 captures->reply(reply_data);
1415 delete captures;
1416 };
1417
1418 FlutterEngineResult create_result = _embedderAPI.PlatformMessageCreateResponseHandle(
1419 _engine, message_reply, captures.get(), &response_handle);
1420 if (create_result != kSuccess) {
1421 NSLog(@"Failed to create a FlutterPlatformMessageResponseHandle (%d)", create_result);
1422 return;
1423 }
1424 captures.release();
1425 }
1426
1427 FlutterPlatformMessage platformMessage = {
1429 .channel = [channel UTF8String],
1430 .message = static_cast<const uint8_t*>(message.bytes),
1431 .message_size = message.length,
1432 .response_handle = response_handle,
1433 };
1434
1435 FlutterEngineResult message_result = _embedderAPI.SendPlatformMessage(_engine, &platformMessage);
1436 if (message_result != kSuccess) {
1437 NSLog(@"Failed to send message to Flutter engine on channel '%@' (%d).", channel,
1438 message_result);
1439 }
1440
1441 if (response_handle != nullptr) {
1442 FlutterEngineResult release_result =
1443 _embedderAPI.PlatformMessageReleaseResponseHandle(_engine, response_handle);
1444 if (release_result != kSuccess) {
1445 NSLog(@"Failed to release the response handle (%d).", release_result);
1446 };
1447 }
1448}
FlutterEngineResult
Definition: embedder.h:72
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition: embedder.h:1164

◆ sendOnChannel:message:binaryReply: [2/2]

- (void) sendOnChannel: (NSString*)  channel
message: (NSData*)  message
binaryReply: (FlutterBinaryReply callback 
implementation

Definition at line 822 of file FlutterEngine.mm.

1248 :(NSString*)channel
1249 message:(NSData*)message
1250 binaryReply:(FlutterBinaryReply)callback {
1251 NSParameterAssert(channel);
1252 NSAssert(_shell && _shell->IsSetup(),
1253 @"Sending a message before the FlutterEngine has been run.");
1255 (callback == nil) ? nullptr
1256 : fml::MakeRefCounted<flutter::PlatformMessageResponseDarwin>(
1257 ^(NSData* reply) {
1258 callback(reply);
1259 },
1260 _shell->GetTaskRunners().GetPlatformTaskRunner());
1261 std::unique_ptr<flutter::PlatformMessage> platformMessage =
1262 (message == nil) ? std::make_unique<flutter::PlatformMessage>(channel.UTF8String, response)
1263 : std::make_unique<flutter::PlatformMessage>(
1264 channel.UTF8String, flutter::CopyNSDataToMapping(message), response);
1265
1266 _shell->GetPlatformView()->DispatchPlatformMessage(std::move(platformMessage));
1267 // platformMessage takes ownership of response.
1268 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
1269}
fml::MallocMapping CopyNSDataToMapping(NSData *data)

◆ sendPointerEvent:

- (void) sendPointerEvent: (const FlutterPointerEvent &)  event
implementation

Dispatches the given pointer event data to engine.

Definition at line 484 of file FlutterEngine.mm.

1009 :(const FlutterPointerEvent&)event {
1010 _embedderAPI.SendPointerEvent(_engine, &event, 1);
1011 _lastViewWithPointerEvent = [self viewControllerForIdentifier:kFlutterImplicitViewId].flutterView;
1012}
__weak FlutterView * _lastViewWithPointerEvent

◆ sendUserLocales

- (void) sendUserLocales
implementation

Sends the list of user-preferred locales to the Flutter engine.

Definition at line 484 of file FlutterEngine.mm.

1048 {
1049 if (!self.running) {
1050 return;
1051 }
1052
1053 // Create a list of FlutterLocales corresponding to the preferred languages.
1054 NSMutableArray<NSLocale*>* locales = [NSMutableArray array];
1055 std::vector<FlutterLocale> flutterLocales;
1056 flutterLocales.reserve(locales.count);
1057 for (NSString* localeID in [NSLocale preferredLanguages]) {
1058 NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:localeID];
1059 [locales addObject:locale];
1060 flutterLocales.push_back(FlutterLocaleFromNSLocale(locale));
1061 }
1062 // Convert to a list of pointers, and send to the engine.
1063 std::vector<const FlutterLocale*> flutterLocaleList;
1064 flutterLocaleList.reserve(flutterLocales.size());
1065 std::transform(flutterLocales.begin(), flutterLocales.end(),
1066 std::back_inserter(flutterLocaleList),
1067 [](const auto& arg) -> const auto* { return &arg; });
1068 _embedderAPI.UpdateLocales(_engine, flutterLocaleList.data(), flutterLocaleList.size());
1069}
static FlutterLocale FlutterLocaleFromNSLocale(NSLocale *locale)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ setApplicationState:

- (void) setApplicationState: (flutter::AppLifecycleState state
implementation

Handles changes to the application state, sending them to the framework.

Parameters
stateOne of the lifecycle constants in app_lifecycle_state.h, corresponding to the Dart enum AppLifecycleState.

Definition at line 484 of file FlutterEngine.mm.

1341 NSString* nextState =
1342 [[NSString alloc] initWithCString:flutter::AppLifecycleStateToString(state)];
1343 [self sendOnChannel:kFlutterLifecycleChannel
1344 message:[nextState dataUsingEncoding:NSUTF8StringEncoding]];
1345}

◆ setBinaryMessenger:

- (void) setBinaryMessenger: (FlutterBinaryMessengerRelay*)  binaryMessenger
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1234 // Discard the previous messenger and keep the new one.
1237 [_binaryMessenger release];
1238 _binaryMessenger = [binaryMessenger retain];
1239 }
1240}
NSObject< FlutterBinaryMessenger > * binaryMessenger

◆ setClipboardData:

- (void) setClipboardData: (NSDictionary*)  data
implementation

Definition at line 484 of file FlutterEngine.mm.

1318 :(NSDictionary*)data {
1319 NSString* text = data[@"text"];
1320 [self.pasteboard clearContents];
1321 if (text && ![text isEqual:[NSNull null]]) {
1322 [self.pasteboard setString:text forType:NSPasteboardTypeString];
1323 }
1324}
std::u16string text

◆ SetEntryPoint

+ (static void) SetEntryPoint (flutter::Settings *)  settings
(NSString *)  entrypoint
(NSString *)  libraryURI 
implementation

Definition at line 822 of file FlutterEngine.mm.

822 {
823 if (libraryURI) {
824 FML_DCHECK(entrypoint) << "Must specify entrypoint if specifying library";
825 settings->advisory_script_entrypoint = entrypoint.UTF8String;
826 settings->advisory_script_uri = libraryURI.UTF8String;
827 } else if (entrypoint) {
828 settings->advisory_script_entrypoint = entrypoint.UTF8String;
829 settings->advisory_script_uri = std::string("main.dart");
830 } else {
831 settings->advisory_script_entrypoint = std::string("main");
832 settings->advisory_script_uri = std::string("main.dart");
833 }
834}

◆ setFlutterViewControllerWillDeallocObserver:

- (void) setFlutterViewControllerWillDeallocObserver: (id<NSObject>)  observer
implementation

Definition at line 157 of file FlutterEngine.mm.

453 :(id<NSObject>)observer {
454 if (observer != _flutterViewControllerWillDeallocObserver) {
455 if (_flutterViewControllerWillDeallocObserver) {
456 [[NSNotificationCenter defaultCenter]
457 removeObserver:_flutterViewControllerWillDeallocObserver];
458 [_flutterViewControllerWillDeallocObserver release];
459 }
460 _flutterViewControllerWillDeallocObserver = [observer retain];
461 }
462}

◆ setIsGpuDisabled:

- (void) setIsGpuDisabled: (BOOL value
implementation

Definition at line 822 of file FlutterEngine.mm.

1387 :(BOOL)value {
1388 if (_shell) {
1391 }
1392 _isGpuDisabled = value;
1393}
uint8_t value
@ kAvailable
Indicates that GPU operations should be permitted.

◆ setMessageHandlerOnChannel:binaryMessageHandler: [1/2]

- (FlutterBinaryMessengerConnection) setMessageHandlerOnChannel: (nonnull NSString*)  channel
binaryMessageHandler: (nullable FlutterBinaryMessageHandler handler 
implementation

Definition at line 484 of file FlutterEngine.mm.

1450 :(nonnull NSString*)channel
1451 binaryMessageHandler:
1452 (nullable FlutterBinaryMessageHandler)handler {
1454 _messengerHandlers[channel] =
1455 [[FlutterEngineHandlerInfo alloc] initWithConnection:@(_currentMessengerConnection)
1456 handler:[handler copy]];
1458}
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
FlutterBinaryMessengerConnection _currentMessengerConnection

◆ setMessageHandlerOnChannel:binaryMessageHandler: [2/2]

- (FlutterBinaryMessengerConnection) setMessageHandlerOnChannel: (NSString*)  channel
binaryMessageHandler: (FlutterBinaryMessageHandler handler 
implementation

Definition at line 822 of file FlutterEngine.mm.

1275 :(NSString*)channel
1276 binaryMessageHandler:
1278 return [self setMessageHandlerOnChannel:channel binaryMessageHandler:handler taskQueue:nil];
1279}

◆ setMessageHandlerOnChannel:binaryMessageHandler:taskQueue:

- (FlutterBinaryMessengerConnection) setMessageHandlerOnChannel: (NSString*)  channel
binaryMessageHandler: (FlutterBinaryMessageHandler handler
taskQueue: (NSObject<FlutterTaskQueue>* _Nullable)  taskQueue 
implementation

Definition at line 822 of file FlutterEngine.mm.

1282 :(NSString*)channel
1283 binaryMessageHandler:(FlutterBinaryMessageHandler)handler
1284 taskQueue:(NSObject<FlutterTaskQueue>* _Nullable)taskQueue {
1285 NSParameterAssert(channel);
1286 if (_shell && _shell->IsSetup()) {
1287 self.iosPlatformView->GetPlatformMessageHandlerIos()->SetMessageHandler(channel.UTF8String,
1288 handler, taskQueue);
1289 return _connections->AquireConnection(channel.UTF8String);
1290 } else {
1291 NSAssert(!handler, @"Setting a message handler before the FlutterEngine has been run.");
1292 // Setting a handler to nil for a channel that has not yet been set up is a no-op.
1294 }
1295}
static Connection MakeErrorConnection(int errCode)

◆ setSemanticsEnabled:

- (void) setSemanticsEnabled: (BOOL enabled
implementation

Definition at line 484 of file FlutterEngine.mm.

1020 :(BOOL)enabled {
1021 if (_semanticsEnabled == enabled) {
1022 return;
1023 }
1024 _semanticsEnabled = enabled;
1025
1026 // Update all view controllers' bridges.
1027 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1028 FlutterViewController* nextViewController;
1029 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1030 [nextViewController notifySemanticsEnabledChanged];
1031 }
1032
1033 _embedderAPI.UpdateSemanticsEnabled(_engine, _semanticsEnabled);
1034}

◆ SetThreadPriority

+ (static void) SetThreadPriority (FlutterThreadPriority priority
implementation

Definition at line 484 of file FlutterEngine.mm.

484 {
485 if (priority == kDisplay || priority == kRaster) {
486 pthread_t thread = pthread_self();
487 sched_param param;
488 int policy;
489 if (!pthread_getschedparam(thread, &policy, &param)) {
490 param.sched_priority = kMainThreadPriority;
491 pthread_setschedparam(thread, policy, &param);
492 }
493 pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
494 }
495}
@ kDisplay
Suitable for threads which generate data for the display.
Definition: embedder.h:264
static const int kMainThreadPriority
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy
Definition: switches.h:248

◆ setUpAccessibilityChannel

- (void) setUpAccessibilityChannel
implementation

Creates an accessibility channel and sets up the message handler.

Definition at line 484 of file FlutterEngine.mm.

1165 {
1167 messageChannelWithName:@"flutter/accessibility"
1168 binaryMessenger:self.binaryMessenger
1170 __weak FlutterEngine* weakSelf = self;
1171 [_accessibilityChannel setMessageHandler:^(id message, FlutterReply reply) {
1172 [weakSelf handleAccessibilityEvent:message];
1173 }];
1174}
FlutterBasicMessageChannel * _accessibilityChannel

◆ setUpApplicationLifecycleNotifications:

- (void) setUpApplicationLifecycleNotifications: (NSNotificationCenter*)  center
implementation

Definition at line 157 of file FlutterEngine.mm.

261 :(NSNotificationCenter*)center {
262 [center addObserver:self
263 selector:@selector(applicationWillEnterForeground:)
264 name:UIApplicationWillEnterForegroundNotification
265 object:nil];
266 [center addObserver:self
267 selector:@selector(applicationDidEnterBackground:)
268 name:UIApplicationDidEnterBackgroundNotification
269 object:nil];
270}

◆ setUpChannels

- (void) setUpChannels
implementation

Definition at line 157 of file FlutterEngine.mm.

583 {
584 // This will be invoked once the shell is done setting up and the isolate ID
585 // for the UI isolate is available.
586 fml::WeakNSObject<FlutterEngine> weakSelf = [self getWeakNSObject];
587 [_binaryMessenger setMessageHandlerOnChannel:@"flutter/isolate"
588 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
589 if (weakSelf) {
590 weakSelf.get().isolateId =
591 [[FlutterStringCodec sharedInstance] decode:message];
592 }
593 }];
594
596 initWithName:@"flutter/localization"
598 codec:[FlutterJSONMethodCodec sharedInstance]]);
599
601 initWithName:@"flutter/navigation"
603 codec:[FlutterJSONMethodCodec sharedInstance]]);
604
605 if ([_initialRoute length] > 0) {
606 // Flutter isn't ready to receive this method call yet but the channel buffer will cache this.
607 [_navigationChannel invokeMethod:@"setInitialRoute" arguments:_initialRoute];
608 [_initialRoute release];
609 _initialRoute = nil;
610 }
611
613 initWithName:@"flutter/restoration"
615 codec:[FlutterStandardMethodCodec sharedInstance]]);
616
618 initWithName:@"flutter/platform"
620 codec:[FlutterJSONMethodCodec sharedInstance]]);
621
623 initWithName:@"flutter/platform_views"
625 codec:[FlutterStandardMethodCodec sharedInstance]]);
626
628 initWithName:@"flutter/textinput"
630 codec:[FlutterJSONMethodCodec sharedInstance]]);
631
633 initWithName:@"flutter/undomanager"
635 codec:[FlutterJSONMethodCodec sharedInstance]]);
636
638 initWithName:@"flutter/scribble"
640 codec:[FlutterJSONMethodCodec sharedInstance]]);
641
643 initWithName:@"flutter/spellcheck"
645 codec:[FlutterStandardMethodCodec sharedInstance]]);
646
648 initWithName:@"flutter/lifecycle"
650 codec:[FlutterStringCodec sharedInstance]]);
651
653 initWithName:@"flutter/system"
655 codec:[FlutterJSONMessageCodec sharedInstance]]);
656
658 initWithName:@"flutter/settings"
660 codec:[FlutterJSONMessageCodec sharedInstance]]);
661
663 initWithName:@"flutter/keyevent"
665 codec:[FlutterJSONMessageCodec sharedInstance]]);
666
667 FlutterTextInputPlugin* textInputPlugin = [[FlutterTextInputPlugin alloc] initWithDelegate:self];
670 [textInputPlugin setUpIndirectScribbleInteraction:self.viewController];
671
673 [[FlutterUndoManagerPlugin alloc] initWithDelegate:self];
675
676 _platformPlugin.reset([[FlutterPlatformPlugin alloc] initWithEngine:[self getWeakNSObject]]);
677
679 initWithChannel:_restorationChannel.get()
680 restorationEnabled:_restorationEnabled]);
682
684 initWithName:@"flutter/screenshot"
686 codec:[FlutterStandardMethodCodec sharedInstance]]);
687
688 [_screenshotChannel.get()
689 setMethodCallHandler:^(FlutterMethodCall* _Nonnull call, FlutterResult _Nonnull result) {
690 if (!(weakSelf.get() && weakSelf.get()->_shell && weakSelf.get()->_shell->IsSetup())) {
691 return result([FlutterError
692 errorWithCode:@"invalid_state"
693 message:@"Requesting screenshot while engine is not running."
694 details:nil]);
695 }
696 flutter::Rasterizer::Screenshot screenshot =
697 [weakSelf.get() screenshot:flutter::Rasterizer::ScreenshotType::SurfaceData
698 base64Encode:NO];
699 if (!screenshot.data) {
700 return result([FlutterError errorWithCode:@"failure"
701 message:@"Unable to get screenshot."
702 details:nil]);
703 }
704 // TODO(gaaclarke): Find way to eliminate this data copy.
705 NSData* data = [NSData dataWithBytes:screenshot.data->writable_data()
706 length:screenshot.data->size()];
707 NSString* format = [NSString stringWithUTF8String:screenshot.format.c_str()];
708 NSNumber* width = @(screenshot.frame_size.fWidth);
709 NSNumber* height = @(screenshot.frame_size.fHeight);
710 return result(@[ width, height, format ?: [NSNull null], data ]);
711 }];
712}
fml::WeakNSObject< FlutterEngine > getWeakNSObject()
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
instancetype sharedInstance()
void setUpIndirectScribbleInteraction:(id< FlutterViewResponder > viewResponder)
id< FlutterIndirectScribbleDelegate > indirectScribbleDelegate
fml::scoped_nsobject< FlutterMethodChannel > _screenshotChannel

◆ setUpNotificationCenterListeners

- (void) setUpNotificationCenterListeners
implementation

Definition at line 484 of file FlutterEngine.mm.

1175 {
1176 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
1177 // macOS fires this private message when VoiceOver turns on or off.
1178 [center addObserver:self
1179 selector:@selector(onAccessibilityStatusChanged:)
1180 name:kEnhancedUserInterfaceNotification
1181 object:nil];
1182 [center addObserver:self
1183 selector:@selector(applicationWillTerminate:)
1184 name:NSApplicationWillTerminateNotification
1185 object:nil];
1186 [center addObserver:self
1187 selector:@selector(windowDidChangeScreen:)
1188 name:NSWindowDidChangeScreenNotification
1189 object:nil];
1190 [center addObserver:self
1191 selector:@selector(updateDisplayConfig:)
1192 name:NSApplicationDidChangeScreenParametersNotification
1193 object:nil];
1194}

◆ setUpPlatformViewChannel

- (void) setUpPlatformViewChannel
implementation

Creates a platform view channel and sets up the method handler.

Definition at line 484 of file FlutterEngine.mm.

1153 {
1155 [FlutterMethodChannel methodChannelWithName:@"flutter/platform_views"
1156 binaryMessenger:self.binaryMessenger
1158
1159 __weak FlutterEngine* weakSelf = self;
1160 [_platformViewsChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1161 [[weakSelf platformViewController] handleMethodCall:call result:result];
1162 }];
1163}

◆ setUpSceneLifecycleNotifications:

- (void) setUpSceneLifecycleNotifications: (ios(13.0))  API_AVAILABLE
implementation

Definition at line 157 of file FlutterEngine.mm.

250 :(NSNotificationCenter*)center API_AVAILABLE(ios(13.0)) {
251 [center addObserver:self
252 selector:@selector(sceneWillEnterForeground:)
253 name:UISceneWillEnterForegroundNotification
254 object:nil];
255 [center addObserver:self
256 selector:@selector(sceneDidEnterBackground:)
257 name:UISceneDidEnterBackgroundNotification
258 object:nil];
259}

◆ setUpShell:withVMServicePublication:

- (void) setUpShell: (std::unique_ptr<flutter::Shell>)  shell
withVMServicePublication: (BOOL doesVMServicePublication 
implementation

Definition at line 157 of file FlutterEngine.mm.

762 :(std::unique_ptr<flutter::Shell>)shell
763 withVMServicePublication:(BOOL)doesVMServicePublication {
764 _shell = std::move(shell);
765 [self setUpChannels];
766 [self onLocaleUpdated:nil];
767 [self updateDisplays];
769 initWithEnableVMServicePublication:doesVMServicePublication]);
770 [self maybeSetupPlatformViewChannels];
771 _shell->SetGpuAvailability(_isGpuDisabled ? flutter::GpuAvailability::kUnavailable
773}
fml::scoped_nsobject< FlutterDartVMServicePublisher > _publisher

◆ setViewController:

- (void) setViewController: (FlutterViewController*)  viewController
implementation

Definition at line 157 of file FlutterEngine.mm.

429 self.iosPlatformView->SetOwnerViewController(_viewController);
430 [self maybeSetupPlatformViewChannels];
431 [self updateDisplays];
432 _textInputPlugin.get().viewController = viewController;
433
434 if (viewController) {
435 __block FlutterEngine* blockSelf = self;
437 [[NSNotificationCenter defaultCenter] addObserverForName:FlutterViewControllerWillDealloc
438 object:viewController
439 queue:[NSOperationQueue mainQueue]
440 usingBlock:^(NSNotification* note) {
441 [blockSelf notifyViewControllerDeallocated];
442 }];
443 } else {
444 self.flutterViewControllerWillDeallocObserver = nil;
445 [self notifyLowMemory];
446 }
447}
flutter::PlatformViewIOS * iosPlatformView()
id< NSObject > flutterViewControllerWillDeallocObserver
fml::WeakNSObject< FlutterViewController > getWeakNSObject()

◆ shell

- (Shell &) FlutterEngine:
implementation

Provided by category FlutterEngine(Test).

Definition at line 157 of file FlutterEngine.mm.

326 {
328 return *_shell;
329}

◆ 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 484 of file FlutterEngine.mm.

1130 {
1131 if (_engine == nullptr) {
1132 return;
1133 }
1134
1135 [_threadSynchronizer shutdown];
1136 _threadSynchronizer = nil;
1137
1138 FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
1139 if (result != kSuccess) {
1140 NSLog(@"Could not de-initialize the Flutter engine: error %d", result);
1141 }
1142
1143 // Balancing release for the retain in the task runner dispatch table.
1144 CFRelease((CFTypeRef)self);
1145
1146 result = _embedderAPI.Shutdown(_engine);
1147 if (result != kSuccess) {
1148 NSLog(@"Failed to shut down Flutter engine: error %d", result);
1149 }
1150 _engine = nullptr;
1151}
FlutterThreadSynchronizer * _threadSynchronizer

◆ shutDownIfNeeded

- (void) shutDownIfNeeded
implementation

Shuts down the engine if view requirement is not met, and headless execution is not allowed.

Definition at line 484 of file FlutterEngine.mm.

804 {
806 [self shutDownEngine];
807 }
808}
int count
Definition: FontMgrTest.cpp:50

◆ spawnWithEntrypoint:libraryURI:initialRoute:entrypointArgs:

- (FlutterEngine *) spawnWithEntrypoint: (/*nullable*/ NSString*)  entrypoint
libraryURI: (/*nullable*/ NSString*)  libraryURI
initialRoute: (/*nullable*/ NSString*)  initialRoute
entrypointArgs: (/*nullable*/ NSArray<NSString*>*)  entrypointArgs 
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1434 :(/*nullable*/ NSString*)entrypoint
1435 libraryURI:(/*nullable*/ NSString*)libraryURI
1436 initialRoute:(/*nullable*/ NSString*)initialRoute
1437 entrypointArgs:(/*nullable*/ NSArray<NSString*>*)entrypointArgs {
1438 NSAssert(_shell, @"Spawning from an engine without a shell (possibly not run).");
1439 FlutterEngine* result = [[FlutterEngine alloc] initWithName:_labelPrefix
1440 project:_dartProject.get()
1441 allowHeadlessExecution:_allowHeadlessExecution];
1442 flutter::RunConfiguration configuration =
1443 [_dartProject.get() runConfigurationForEntrypoint:entrypoint
1444 libraryOrNil:libraryURI
1445 entrypointArgs:entrypointArgs];
1446
1449 // Static-cast safe since this class always creates PlatformViewIOS instances.
1450 flutter::PlatformViewIOS* ios_platform_view =
1451 static_cast<flutter::PlatformViewIOS*>(platform_view.get());
1452 std::shared_ptr<flutter::IOSContext> context = ios_platform_view->GetIosContext();
1453 FML_DCHECK(context);
1454
1455 // Lambda captures by pointers to ObjC objects are fine here because the
1456 // create call is synchronous.
1458 [result, context](flutter::Shell& shell) {
1460 return std::make_unique<flutter::PlatformViewIOS>(
1461 shell, context, result->_platformViewsController, shell.GetTaskRunners());
1462 };
1463
1465 [](flutter::Shell& shell) { return std::make_unique<flutter::Rasterizer>(shell); };
1466
1467 std::string cppInitialRoute;
1468 if (initialRoute) {
1469 cppInitialRoute = [initialRoute UTF8String];
1470 }
1471
1472 std::unique_ptr<flutter::Shell> shell = _shell->Spawn(
1473 std::move(configuration), cppInitialRoute, on_create_platform_view, on_create_rasterizer);
1474
1475 result->_threadHost = _threadHost;
1476 result->_profiler = _profiler;
1477 result->_profiler_metrics = _profiler_metrics;
1478 result->_isGpuDisabled = _isGpuDisabled;
1479 [result setUpShell:std::move(shell) withVMServicePublication:NO];
1480 return [result autorelease];
1481}
const std::shared_ptr< IOSContext > & GetIosContext()
Specifies all the configuration required by the runtime library to launch the root isolate....
void recreatePlatformViewController()
std::shared_ptr< flutter::ProfilerMetricsIOS > _profiler_metrics

◆ spellCheckChannel

- (FlutterMethodChannel *) spellCheckChannel
implementation

Definition at line 157 of file FlutterEngine.mm.

531 {
532 return _spellCheckChannel.get();
533}

◆ startProfiler

- (void) startProfiler
implementation

Definition at line 157 of file FlutterEngine.mm.

571 {
572 FML_DCHECK(!_threadHost->name_prefix.empty());
573 _profiler_metrics = std::make_shared<flutter::ProfilerMetricsIOS>();
574 _profiler = std::make_shared<flutter::SamplingProfiler>(
575 _threadHost->name_prefix.c_str(), _threadHost->profiler_thread->GetTaskRunner(),
576 [self]() { return self->_profiler_metrics->GenerateSample(); }, kNumProfilerSamplesPerSec);
577 _profiler->Start();
578}
static constexpr int kNumProfilerSamplesPerSec

◆ switches

- (vector<) std:
implementation

The command line arguments array for the engine.

Definition at line 484 of file FlutterEngine.mm.

1330 {
1332}
std::vector< std::string > GetSwitchesFromEnvironment()

◆ takeScreenshot:asBase64Encoded:

- Rasterizer: (flutter::Rasterizer::ScreenshotType type
asBase64Encoded: (BOOL base64Encode 
implementation

Reimplemented from <FlutterViewEngineDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1212 asBase64Encoded:(BOOL)base64Encode {
1213 FML_DCHECK(_shell) << "Cannot takeScreenshot without a shell";
1214 return _shell->Screenshot(type, base64Encode);
1215}

◆ testThreadSynchronizer

- (FlutterThreadSynchronizer *) testThreadSynchronizer
implementation

Provided by category FlutterEngine(Tests).

Definition at line 484 of file FlutterEngine.mm.

1334 {
1335 return _threadSynchronizer;
1336}

◆ textInputPlugin

- (FlutterTextInputPlugin *) textInputPlugin
implementation

Reimplemented in FlutterEnginePartialMock.

Definition at line 157 of file FlutterEngine.mm.

501 {
502 return _textInputPlugin.get();
503}

◆ textureFrameAvailable:

- (void) textureFrameAvailable: (int64_t)  textureId
implementation

Notifies Flutter that the content of the previously registered texture has been updated.

This will trigger a call to -[FlutterTexture copyPixelBuffer] on the raster thread.

Reimplemented from <FlutterTextureRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1319 :(int64_t)textureId {
1320 _shell->GetPlatformView()->MarkTextureFrameAvailable(textureId);
1321}

◆ threadHost

- (const ThreadHost &) FlutterEngine:
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1483 {
1484 return *_threadHost;
1485}

◆ uiTaskRunner

- (RefPtr<) fml:
implementation

Definition at line 157 of file FlutterEngine.mm.

364 {
366 return _shell->GetTaskRunners().GetUITaskRunner();
367}

◆ undoManager

- (NSUndoManager *) undoManager
implementation

The NSUndoManager that should be managed by the FlutterUndoManagerPlugin. When the delegate is FlutterEngine this will be the FlutterViewController's undo manager.

Reimplemented from <FlutterUndoManagerDelegate>.

Definition at line 822 of file FlutterEngine.mm.

1205 {
1206 return self.viewController.undoManager;
1207}

◆ undoManagerChannel

- (FlutterMethodChannel *) undoManagerChannel
implementation

Definition at line 157 of file FlutterEngine.mm.

525 {
526 return _undoManagerChannel.get();
527}

◆ undoManagerPlugin

- (FlutterUndoManagerPlugin *) undoManagerPlugin
implementation

Definition at line 157 of file FlutterEngine.mm.

504 {
505 return _undoManagerPlugin.get();
506}

◆ unregisterTexture:

- (void) unregisterTexture: (int64_t)  textureId
implementation

Unregisters a FlutterTexture that has previously regeistered with registerTexture:. Textures must be unregistered on the platform thread.

Parameters
textureIdThe result that was previously returned from registerTexture:.

Reimplemented from <FlutterTextureRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1315 :(int64_t)textureId {
1316 _shell->GetPlatformView()->UnregisterTexture(textureId);
1317}

◆ unregisterTextureWithID:

- (BOOL) unregisterTextureWithID: (int64_t)  textureID
implementation

Unregisters an external texture with the given id. Returns YES on success.

Definition at line 484 of file FlutterEngine.mm.

1515 :(int64_t)textureID {
1516 return _embedderAPI.UnregisterExternalTexture(_engine, textureID) == kSuccess;
1517}

◆ updateDisplayConfig

- (void) updateDisplayConfig
implementation

Definition at line 484 of file FlutterEngine.mm.

916 {
917 if (!_engine) {
918 return;
919 }
920
921 std::vector<FlutterEngineDisplay> displays;
922 for (NSScreen* screen : [self screens]) {
923 CGDirectDisplayID displayID =
924 static_cast<CGDirectDisplayID>([screen.deviceDescription[@"NSScreenNumber"] integerValue]);
925
926 double devicePixelRatio = screen.backingScaleFactor;
927 FlutterEngineDisplay display;
928 display.struct_size = sizeof(display);
929 display.display_id = displayID;
930 display.single_display = false;
931 display.width = static_cast<size_t>(screen.frame.size.width) * devicePixelRatio;
932 display.height = static_cast<size_t>(screen.frame.size.height) * devicePixelRatio;
933 display.device_pixel_ratio = devicePixelRatio;
934
935 CVDisplayLinkRef displayLinkRef = nil;
936 CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &displayLinkRef);
937
938 if (error == 0) {
939 CVTime nominal = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLinkRef);
940 if (!(nominal.flags & kCVTimeIsIndefinite)) {
941 double refreshRate = static_cast<double>(nominal.timeScale) / nominal.timeValue;
942 display.refresh_rate = round(refreshRate);
943 }
944 CVDisplayLinkRelease(displayLinkRef);
945 } else {
946 display.refresh_rate = 0;
947 }
948
949 displays.push_back(display);
950 }
951 _embedderAPI.NotifyDisplayUpdate(_engine, kFlutterEngineDisplaysUpdateTypeStartup,
952 displays.data(), displays.size());
953}
static void round(SkPoint *p)
@ kFlutterEngineDisplaysUpdateTypeStartup
Definition: embedder.h:2006
const uint8_t uint32_t uint32_t GError ** error
NSArray< NSScreen * > * screens()
size_t height
The height of the display, in physical pixels.
Definition: embedder.h:1991
double device_pixel_ratio
Definition: embedder.h:1995
size_t struct_size
This size of this struct. Must be sizeof(FlutterDisplay).
Definition: embedder.h:1973
size_t width
The width of the display, in physical pixels.
Definition: embedder.h:1988
FlutterEngineDisplayId display_id
Definition: embedder.h:1975

◆ updateDisplayConfig:

- (void) updateDisplayConfig: (NSNotification*)  notification
implementation

Definition at line 484 of file FlutterEngine.mm.

908 :(NSNotification*)notification {
909 [self updateDisplayConfig];
910}

◆ updateDisplays

- (void) updateDisplays
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

922 {
923 if (!_shell) {
924 // Tests may do this.
925 return;
926 }
927 auto vsync_waiter = _shell->GetVsyncWaiter().lock();
928 auto vsync_waiter_ios = std::static_pointer_cast<flutter::VsyncWaiterIOS>(vsync_waiter);
929 std::vector<std::unique_ptr<flutter::Display>> displays;
930 auto screen_size = UIScreen.mainScreen.nativeBounds.size;
931 auto scale = UIScreen.mainScreen.scale;
932 displays.push_back(std::make_unique<flutter::VariableRefreshRateDisplay>(
933 0, vsync_waiter_ios, screen_size.width, screen_size.height, scale));
934 _shell->OnDisplayUpdates(std::move(displays));
935}
const Scalar scale

◆ updateViewportMetrics:

- (void) updateViewportMetrics: (flutter::ViewportMetrics viewportMetrics
implementation

Definition at line 157 of file FlutterEngine.mm.

335 :(flutter::ViewportMetrics)viewportMetrics {
336 if (!self.platformView) {
337 return;
338 }
339 self.platformView->SetViewportMetrics(flutter::kFlutterImplicitViewId, viewportMetrics);
340}
constexpr int64_t kFlutterImplicitViewId
Definition: constants.h:35

◆ updateWindowMetricsForViewController:

- (void) updateWindowMetricsForViewController: (FlutterViewController *)  viewController
implementation

Informs the engine that the specified view controller's window metrics have changed.

Definition at line 484 of file FlutterEngine.mm.

986 if (!_engine || !viewController || !viewController.viewLoaded) {
987 return;
988 }
989 NSAssert([self viewControllerForIdentifier:viewController.viewIdentifier] == viewController,
990 @"The provided view controller is not attached to this engine.");
991 NSView* view = viewController.flutterView;
992 CGRect scaledBounds = [view convertRectToBacking:view.bounds];
993 CGSize scaledSize = scaledBounds.size;
994 double pixelRatio = view.bounds.size.width == 0 ? 1 : scaledSize.width / view.bounds.size.width;
995 auto displayId = [view.window.screen.deviceDescription[@"NSScreenNumber"] integerValue];
996 const FlutterWindowMetricsEvent windowMetricsEvent = {
997 .struct_size = sizeof(windowMetricsEvent),
998 .width = static_cast<size_t>(scaledSize.width),
999 .height = static_cast<size_t>(scaledSize.height),
1000 .pixel_ratio = pixelRatio,
1001 .left = static_cast<size_t>(scaledBounds.origin.x),
1002 .top = static_cast<size_t>(scaledBounds.origin.y),
1003 .display_id = static_cast<uint64_t>(displayId),
1004 .view_id = viewController.viewIdentifier,
1005 };
1006 _embedderAPI.SendWindowMetricsEvent(_engine, &windowMetricsEvent);
1007}
static bool left(const SkPoint &p0, const SkPoint &p1)
int32_t width
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
Definition: embedder.h:843

◆ valuePublishedByPlugin:

- (nullable NSObject *) valuePublishedByPlugin: (NSString *)  pluginKey
implementation

Returns a value published by the specified plugin.

Parameters
pluginKeyThe unique key identifying the plugin.
Returns
An object published by the plugin, if any. Will be NSNull if nothing has been published. Will be nil if the plugin has not been registered.

Reimplemented from <FlutterPluginRegistry>.

Definition at line 822 of file FlutterEngine.mm.

1350 :(NSString*)pluginKey {
1351 return _pluginPublications[pluginKey];
1352}

◆ viewControllerForIdentifier:

- (FlutterViewController *) viewControllerForIdentifier: (FlutterViewIdentifier viewIdentifier
implementation

Definition at line 484 of file FlutterEngine.mm.

810 :(FlutterViewIdentifier)viewIdentifier {
811 FlutterViewController* controller = [_viewControllers objectForKey:@(viewIdentifier)];
812 NSAssert(controller == nil || controller.viewIdentifier == viewIdentifier,
813 @"The stored controller has unexpected view ID.");
814 return controller;
815}

◆ viewControllerViewDidLoad:

- (void) viewControllerViewDidLoad: (FlutterViewController *)  viewController
implementation

Notify the engine that a view for the given view controller has been loaded.

Definition at line 484 of file FlutterEngine.mm.

761 __weak FlutterEngine* weakSelf = self;
762 FlutterTimeConverter* timeConverter = [[FlutterTimeConverter alloc] initWithEngine:self];
763 FlutterVSyncWaiter* waiter = [[FlutterVSyncWaiter alloc]
764 initWithDisplayLink:[FlutterDisplayLink displayLinkWithView:viewController.view]
765 block:^(CFTimeInterval timestamp, CFTimeInterval targetTimestamp,
766 uintptr_t baton) {
767 uint64_t timeNanos = [timeConverter CAMediaTimeToEngineTime:timestamp];
768 uint64_t targetTimeNanos =
769 [timeConverter CAMediaTimeToEngineTime:targetTimestamp];
770 FlutterEngine* engine = weakSelf;
771 if (engine) {
772 // It is a bit unfortunate that embedder requires OnVSync call on
773 // platform thread just to immediately redispatch it to UI thread.
774 // We are already on UI thread right now, but have to do the
775 // extra hop to main thread.
776 [engine->_threadSynchronizer performOnPlatformThread:^{
777 engine->_embedderAPI.OnVsync(_engine, baton, timeNanos, targetTimeNanos);
778 }];
779 }
780 }];
781 FML_DCHECK([_vsyncWaiters objectForKey:@(viewController.viewIdentifier)] == nil);
782 @synchronized(_vsyncWaiters) {
783 [_vsyncWaiters setObject:waiter forKey:@(viewController.viewIdentifier)];
784 }
785}
uint64_t CAMediaTimeToEngineTime:(CFTimeInterval time)

◆ waitForFirstFrame:callback:

- (void) waitForFirstFrame: (NSTimeInterval)  timeout
callback: (void(^_Nonnull)(BOOL didTimeout))  callback 
implementation

Provided by category FlutterEngine(Test).

Definition at line 822 of file FlutterEngine.mm.

1421 :(NSTimeInterval)timeout
1422 callback:(void (^_Nonnull)(BOOL didTimeout))callback {
1423 dispatch_queue_t queue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0);
1424 dispatch_async(queue, ^{
1426 BOOL didTimeout =
1427 self.shell.WaitForFirstFrame(waitTime).code() == fml::StatusCode::kDeadlineExceeded;
1428 dispatch_async(dispatch_get_main_queue(), ^{
1429 callback(didTimeout);
1430 });
1431 });
1432}
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46
VkQueue queue
Definition: main.cc:55
def timeout(deadline, cmd)

◆ windowDidChangeScreen:

- (void) windowDidChangeScreen: (NSNotification*)  notification
implementation

Definition at line 484 of file FlutterEngine.mm.

1225 :(NSNotification*)notification {
1226 // Update window metric for all view controllers since the display_id has
1227 // changed.
1228 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1229 FlutterViewController* nextViewController;
1230 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1231 [self updateWindowMetricsForViewController:nextViewController];
1232 }
1233}

Member Data Documentation

◆ __pad0__

- __pad0__
protected

Definition at line 29 of file FlutterEngine.h.

◆ FlutterPluginRegistry

- FlutterPluginRegistry
protected

Definition at line 31 of file FlutterEngine.h.

Property Documentation

◆ binaryMessenger [1/2]

- (id< FlutterBinaryMessenger >) binaryMessenger
readnonatomicassign

The FlutterBinaryMessenger associated with this FlutterEngine (used for communicating with channels).

Definition at line 437 of file FlutterEngine.h.

◆ binaryMessenger [2/2]

- (id<FlutterBinaryMessenger>) binaryMessenger
readnonatomicassign

The FlutterBinaryMessenger for communicating with this engine.

Definition at line 91 of file FlutterEngine.h.

◆ enableEmbedderAPI

- (BOOL) enableEmbedderAPI
readwritenonatomicassignimplementation

Provided by category FlutterEngine(Test).

Definition at line 110 of file FlutterEngine.mm.

◆ flutterViewControllerWillDeallocObserver

- (id<NSObject>) flutterViewControllerWillDeallocObserver
readwritenonatomicretainimplementation

Definition at line 106 of file FlutterEngine.mm.

◆ initialRoute

- (NSString*) initialRoute
readwritenonatomiccopyimplementation

Definition at line 105 of file FlutterEngine.mm.

◆ isGpuDisabled

- (BOOL) isGpuDisabled
readwritenonatomicassign

Whether or not GPU calls are allowed.

Typically this is set when the app is backgrounded and foregrounded.

Definition at line 456 of file FlutterEngine.h.

◆ isolateId

- (NSString*) isolateId
readnonatomiccopy

The UI Isolate ID of the engine.

This property will be nil if the engine is not running.

Definition at line 449 of file FlutterEngine.h.

◆ isResponseValid

- (NSMutableArray<NSNumber*>*) isResponseValid
readwritenonatomicstrongimplementation

A mutable array that holds one bool value that determines if responses to platform messages are clear to execute. This value should be read or written only inside of a synchronized block and will return NO after the FlutterEngine has been dealloc'd.

Definition at line 99 of file FlutterEngine.mm.

◆ keyEventChannel

- (FlutterBasicMessageChannel *) keyEventChannel
readnonatomicassign

The FlutterBasicMessageChannel used for communicating key events from physical keyboards

Can be nil after destroyContext is called.

Definition at line 412 of file FlutterEngine.h.

◆ lifecycleChannel

- (FlutterBasicMessageChannel *) lifecycleChannel
readnonatomicassign

The FlutterBasicMessageChannel used to communicate app lifecycle events to the Dart Isolate.

Can be nil after destroyContext is called.

See also
Lifecycle Channel

Definition at line 385 of file FlutterEngine.h.

◆ localizationChannel

- (FlutterMethodChannel *) localizationChannel
readnonatomicassign

The FlutterMethodChannel used for localization related platform messages, such as setting the locale.

Can be nil after destroyContext is called.

Definition at line 335 of file FlutterEngine.h.

◆ navigationChannel

- (FlutterMethodChannel *) navigationChannel
readnonatomicassign

The FlutterMethodChannel used for navigation related platform messages.

Can be nil after destroyContext is called.

See also
Navigation Channel
Navigator Widget

Definition at line 345 of file FlutterEngine.h.

◆ pasteboard

- (FlutterPasteboard*) pasteboard
readwritenonatomicassignimplementation

This just returns the NSPasteboard so that it can be mocked in the tests.

Definition at line 112 of file FlutterEngine_Internal.h.

◆ platformChannel

- (FlutterMethodChannel *) platformChannel
readnonatomicassign

The FlutterMethodChannel used for core platform messages, such as information about the screen orientation.

Can be nil after destroyContext is called.

Definition at line 363 of file FlutterEngine.h.

◆ pluginAppDelegates

- (NSPointerArray*) pluginAppDelegates
readwritenonatomicstrongimplementation

All delegates added via plugin calls to addApplicationDelegate.

Definition at line 104 of file FlutterEngine.mm.

◆ pluginPublications

- (NSMutableDictionary*) pluginPublications
readnonatomicassignimplementation

Definition at line 101 of file FlutterEngine.mm.

◆ pluginRegistrars

- (NSMutableDictionary<NSString*, FlutterEngineRegistrar*>*) pluginRegistrars
readnonatomicassignimplementation

All registrars returned from registrarForPlugin:

Definition at line 110 of file FlutterEngine.mm.

◆ registrars

- (NSMutableDictionary<NSString*, FlutterEngineRegistrar*>*) registrars
readnonatomicassignimplementation

Definition at line 102 of file FlutterEngine.mm.

◆ renderer

- (FlutterRenderer*) renderer
readnonatomicassignimplementation

Provides the renderer config needed to initialize the engine and also handles external texture management.

Definition at line 91 of file FlutterEngine_Internal.h.

◆ restorationChannel

- (FlutterMethodChannel *) restorationChannel
readnonatomicassign

The FlutterMethodChannel used for restoration related platform messages.

Can be nil after destroyContext is called.

See also
Restoration Channel

Definition at line 355 of file FlutterEngine.h.

◆ semanticsEnabled

- (BOOL) semanticsEnabled
readwritenonatomicassignimplementation

True if the semantics is enabled. The Flutter framework starts sending semantics update through the embedder as soon as it is set to YES.

Definition at line 102 of file FlutterEngine_Internal.h.

◆ settingsChannel

- (FlutterBasicMessageChannel *) settingsChannel
readnonatomicassign

The FlutterBasicMessageChannel used for communicating user settings such as clock format and text scale.

Can be nil after destroyContext is called.

Definition at line 404 of file FlutterEngine.h.

◆ systemChannel

- (FlutterBasicMessageChannel *) systemChannel
readnonatomicassign

The FlutterBasicMessageChannel used for communicating system events, such as memory pressure events.

Can be nil after destroyContext is called.

See also
System Channel

Definition at line 396 of file FlutterEngine.h.

◆ terminationHandler

- (FlutterEngineTerminationHandler*) terminationHandler
readnonatomicassignimplementation

Provides the |FlutterEngineTerminationHandler| to be used for this engine.

Definition at line 122 of file FlutterEngine_Internal.h.

◆ textInputChannel

- (FlutterMethodChannel *) textInputChannel
readnonatomicassign

The FlutterMethodChannel used to communicate text input events to the Dart Isolate.

Can be nil after destroyContext is called.

See also
Text Input Channel

Definition at line 374 of file FlutterEngine.h.

◆ textureRegistry

- (NSObject< FlutterTextureRegistry > *) textureRegistry
readnonatomicassign

The FlutterTextureRegistry associated with this FlutterEngine (used to register textures).

Definition at line 442 of file FlutterEngine.h.

◆ viewController

- (FlutterViewController *) viewController
readwritenonatomicweak

Sets the FlutterViewController for this instance. The FlutterEngine must be running (e.g. a successful call to -runWithEntrypoint: or -runWithEntrypoint:libraryURI) before calling this method. Callers may pass nil to remove the viewController and have the engine run headless in the current process.

A FlutterEngine can only have one FlutterViewController at a time. If there is already a FlutterViewController associated with this instance, this method will replace the engine's current viewController with the newly specified one.

Setting the viewController will signal the engine to start animations and drawing, and unsetting it will signal the engine to stop animations and drawing. However, neither will impact the state of the Dart program's execution.

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 327 of file FlutterEngine.h.

◆ vmServiceUrl

- (NSURL *) vmServiceUrl
readnonatomicassign

The NSURL of the Dart VM Service for the service isolate.

This is only set in debug and profile runtime modes, and only after the Dart VM Service is ready. In release mode or before the Dart VM Service has started, it returns nil.

Definition at line 431 of file FlutterEngine.h.


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