Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Class Methods | Protected Attributes | Properties | List of all members
FlutterEngine Class Reference

#include <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.
 
(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>
(nonnull id< FlutterPluginRegistrar >) - registrarForPlugin:
 
(nullable NSObject *) - valuePublishedByPlugin:
 
- Instance Methods inherited from <FlutterBinaryMessenger>
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler:taskQueue:
 
(void) - sendOnChannel:message:
 
(FlutterBinaryMessengerConnection- setMessageHandlerOnChannel:binaryMessageHandler:
 
- 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

 : 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>
- Properties inherited from <FlutterViewEngineDelegate>

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

1195 {
1196 __weak FlutterEngine* weakSelf = self;
1197 [FlutterMouseCursorPlugin registerWithRegistrar:[self registrarForPlugin:@"mousecursor"]
1198 delegate:self];
1199 [FlutterMenuPlugin registerWithRegistrar:[self registrarForPlugin:@"menu"]];
1201 [FlutterBasicMessageChannel messageChannelWithName:kFlutterSettingsChannel
1202 binaryMessenger:self.binaryMessenger
1205 [FlutterMethodChannel methodChannelWithName:kFlutterPlatformChannel
1206 binaryMessenger:self.binaryMessenger
1208 [_platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1209 [weakSelf handleMethodCall:call result:result];
1210 }];
1211}
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 483 of file FlutterEngine.mm.

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

◆ announceAccessibilityMessage:withPriority:

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

Announces accessibility messages.

Definition at line 483 of file FlutterEngine.mm.

1261 :(NSString*)message
1262 withPriority:(NSAccessibilityPriorityLevel)priority {
1263 NSAccessibilityPostNotificationWithUserInfo(
1264 [self viewControllerForIdentifier:kFlutterImplicitViewId].flutterView,
1265 NSAccessibilityAnnouncementRequestedNotification,
1266 @{NSAccessibilityAnnouncementKey : message, NSAccessibilityPriorityKey : @(priority)});
1267}
Win32Message message
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35

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

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

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

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

◆ createFlutterCompositor

- (FlutterCompositor *) createFlutterCompositor
implementation

Definition at line 483 of file FlutterEngine.mm.

853 {
854 _macOSCompositor = std::make_unique<flutter::FlutterCompositor>(
855 [[FlutterViewEngineProvider alloc] initWithEngine:self],
856 [[FlutterTimeConverter alloc] initWithEngine:self], _platformViewController);
857
858 _compositor = {};
861
863 FlutterBackingStore* backing_store_out, //
864 void* user_data //
865 ) {
866 return reinterpret_cast<flutter::FlutterCompositor*>(user_data)->CreateBackingStore(
867 config, backing_store_out);
868 };
869
871 void* user_data //
872 ) { return true; };
873
875 return reinterpret_cast<flutter::FlutterCompositor*>(info->user_data)
876 ->Present(info->view_id, info->layers, info->layers_count);
877 };
878
880
881 return &_compositor;
882}
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:1901
bool avoid_backing_store_cache
Avoid caching backing stores provided by this compositor.
Definition embedder.h:1921
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition embedder.h:1885
FlutterPresentViewCallback present_view_callback
Definition embedder.h:1930
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition embedder.h:1906

◆ 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}
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:167
const std::shared_ptr< fml::ConcurrentTaskRunner > GetConcurrentWorkerTaskRunner() const
Definition shell.cc:2316
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
Definition shell.cc:799
std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const override
Accessor for the disable GPU SyncSwitch.
Definition shell.cc:2249
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition shell.h:119
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
if(end==-1)
#define FML_LOG(severity)
Definition logging.h:82
flutter::Shell & shell()
NSString * initialRoute
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)

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

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

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

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

1036 toTarget:(uint16_t)target
1037 withData:(fml::MallocMapping)data {
1038 _embedderAPI.DispatchSemanticsAction(_engine, target, action, data.GetMapping(), data.GetSize());
1039}
FlutterSemanticsAction
Definition embedder.h:113
uint32_t * target
fml::scoped_nsobject< FlutterEngine > _engine
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ embedderAPI

- (FlutterEngineProcTable &) embedderAPI
implementation

Function pointers for interacting with the embedder.h API.

Provided by category FlutterEngine(Test).

Definition at line 483 of file FlutterEngine.mm.

976 {
977 return _embedderAPI;
978}

◆ engineCallbackOnPlatformMessage:

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

Handles a platform message from the engine.

Definition at line 483 of file FlutterEngine.mm.

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

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

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

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

◆ 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
1106 invokeMethod:@"TextInputClient.focusElement"
1107 arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
1109}
void(^ FlutterResult)(id _Nullable result)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
FlutterTextInputPlugin * textInputPlugin()
fml::scoped_nsobject< FlutterMethodChannel > _textInputChannel
double y
double x
const myers::Point & get(const myers::Segment &)

◆ 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
1118 invokeMethod:@"TextInputClient.requestElementsInRect"
1119 arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
1121}
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
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
int32_t height
int32_t width

◆ 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}
Type::kYUV Type::kRGBA() int(0.7 *637)

◆ 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}

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

1309 :(NSString*)format {
1310 if ([format isEqualToString:@(kTextPlainFormat)]) {
1311 NSString* stringInPasteboard = [self.pasteboard stringForType:NSPasteboardTypeString];
1312 return stringInPasteboard == nil ? nil : @{@"text" : stringInPasteboard};
1313 }
1314 return nil;
1315}
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 483 of file FlutterEngine.mm.

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

◆ handleDidChangeOcclusionState:

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

Called when the |FlutterAppDelegate| gets the applicationDidUnhide notification.

Definition at line 483 of file FlutterEngine.mm.

1376 :(NSNotification*)notification {
1377 NSApplicationOcclusionState occlusionState = [[NSApplication sharedApplication] occlusionState];
1378 if (occlusionState & NSApplicationOcclusionStateVisible) {
1379 _visible = YES;
1380 if (_active) {
1381 [self setApplicationState:flutter::AppLifecycleState::kResumed];
1382 } else {
1383 [self setApplicationState:flutter::AppLifecycleState::kInactive];
1384 }
1385 } else {
1386 _visible = NO;
1387 [self setApplicationState:flutter::AppLifecycleState::kHidden];
1388 }
1389}
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 483 of file FlutterEngine.mm.

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

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

◆ handleWillResignActive:

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

Called when the |FlutterAppDelegate| gets the applicationWillResignActive notification.

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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
177 allowHeadlessExecution:allowHeadlessExecution
178 restorationEnabled:NO];
179}
int BOOL

◆ 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:3329
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...
Function-pointer-based versions of the APIs above.
Definition embedder.h:3317

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

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

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

◆ 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
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()
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
@ kDisplay
Suitable for threads which generate data for the display.
static void IOSPlatformThreadConfigSetter(const fml::Thread::ThreadConfig &config)
static std::string MakeThreadName(Type type, const std::string &prefix)
Use the prefix and thread type to generator a thread name.
The collection of all the threads used by the engine.
Definition thread_host.h:21
The ThreadConfig is the thread info include thread name, thread priority.
Definition thread.h:35

◆ markTextureFrameAvailable:

- (BOOL) markTextureFrameAvailable: (int64_t)  textureID
implementation

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

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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:724
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) {
473 }
474 }
475 [_textInputPlugin.get() resetViewResponder];
476 _viewController.reset();
477}
std::unique_ptr< flutter::PlatformViewIOS > platform_view
void SetOwnerViewController(const fml::WeakNSObject< FlutterViewController > &owner_controller)
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 483 of file FlutterEngine.mm.

1234 :(NSNotification*)notification {
1235 BOOL enabled = [notification.userInfo[kEnhancedUserInterfaceKey] boolValue];
1236 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1237 FlutterViewController* nextViewController;
1238 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1239 [nextViewController onAccessibilityStatusChanged:enabled];
1240 }
1241
1242 self.semanticsEnabled = enabled;
1243}
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 483 of file FlutterEngine.mm.

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

◆ onVSync:

- (void) onVSync: (uintptr_t)  baton
implementation

Definition at line 483 of file FlutterEngine.mm.

1117 :(uintptr_t)baton {
1118 @synchronized(_vsyncWaiters) {
1119 // TODO(knopp): Use vsync waiter for correct view.
1120 // https://github.com/flutter/flutter/issues/142845
1121 FlutterVSyncWaiter* waiter = [_vsyncWaiters objectForKey:@(kFlutterImplicitViewId)];
1122 [waiter waitForVSync:baton];
1123 }
1124}
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 483 of file FlutterEngine.mm.

1041 {
1043}

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

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

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

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

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

1494 :(id<FlutterTexture>)texture {
1495 return [_renderer registerTexture:texture];
1496}
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 483 of file FlutterEngine.mm.

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

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

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

◆ removeViewController:

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

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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

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

903 {
904 return _engine != nullptr;
905}

◆ runTaskOnEmbedder:

- (void) runTaskOnEmbedder: (FlutterTask task
implementation

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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
947}
NSString *const FlutterDefaultInitialRoute

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

911 {
912 return [NSScreen screens];
913}

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

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

◆ 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:1153
@ kFlutterKeyEventTypeDown
Definition embedder.h:1074
@ kFlutterKeyEventTypeUp
Definition embedder.h:1073
@ kFlutterKeyEventTypeRepeat
Definition embedder.h:1075
FlKeyEvent * event
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
return FALSE
SK_API sk_sp< SkSurface > ios(9.0)
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 483 of file FlutterEngine.mm.

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

◆ sendOnChannel:message: [1/2]

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

Definition at line 483 of file FlutterEngine.mm.

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

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

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

◆ 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)
RefPtr< T > MakeRefCounted(Args &&... args)
Definition ref_ptr.h:248

◆ sendPointerEvent:

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

Dispatches the given pointer event data to engine.

Definition at line 483 of file FlutterEngine.mm.

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

◆ sendUserLocales

- (void) sendUserLocales
implementation

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

Definition at line 483 of file FlutterEngine.mm.

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

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

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

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

1317 :(NSDictionary*)data {
1318 NSString* text = data[@"text"];
1319 [self.pasteboard clearContents];
1320 if (text && ![text isEqual:[NSNull null]]) {
1321 [self.pasteboard setString:text forType:NSPasteboardTypeString];
1322 }
1323}
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) {
1389 _shell->SetGpuAvailability(value ? flutter::GpuAvailability::kUnavailable
1391 }
1392 _isGpuDisabled = value;
1393}
uint8_t value
GpuAvailability
Values for |Shell::SetGpuAvailability|.
Definition shell.h:62
@ 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 483 of file FlutterEngine.mm.

1449 :(nonnull NSString*)channel
1450 binaryMessageHandler:
1451 (nullable FlutterBinaryMessageHandler)handler {
1453 _messengerHandlers[channel] =
1454 [[FlutterEngineHandlerInfo alloc] initWithConnection:@(_currentMessengerConnection)
1455 handler:[handler copy]];
1457}
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 483 of file FlutterEngine.mm.

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

◆ SetThreadPriority

+ (static void) SetThreadPriority (FlutterThreadPriority priority
implementation

Definition at line 483 of file FlutterEngine.mm.

483 {
484 if (priority == kDisplay || priority == kRaster) {
485 pthread_t thread = pthread_self();
486 sched_param param;
487 int policy;
488 if (!pthread_getschedparam(thread, &policy, &param)) {
489 param.sched_priority = kMainThreadPriority;
490 pthread_setschedparam(thread, policy, &param);
491 }
492 pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
493 }
494}
@ kDisplay
Suitable for threads which generate data for the display.
Definition embedder.h:262
@ kRaster
Suitable for thread which raster data.
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 483 of file FlutterEngine.mm.

1164 {
1166 messageChannelWithName:@"flutter/accessibility"
1167 binaryMessenger:self.binaryMessenger
1169 __weak FlutterEngine* weakSelf = self;
1170 [_accessibilityChannel setMessageHandler:^(id message, FlutterReply reply) {
1171 [weakSelf handleAccessibilityEvent:message];
1172 }];
1173}
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 483 of file FlutterEngine.mm.

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

◆ setUpPlatformViewChannel

- (void) setUpPlatformViewChannel
implementation

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

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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
Definition ref_ptr.h:256

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

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

803 {
805 [self shutDownEngine];
806 }
807}
int count

◆ 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....
std::unique_ptr< Shell > Spawn(RunConfiguration run_configuration, const std::string &initial_route, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer) const
Creates one Shell from another Shell where the created Shell takes the opportunity to share any inter...
Definition shell.cc:589
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 483 of file FlutterEngine.mm.

1329 {
1331}
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 483 of file FlutterEngine.mm.

1333 {
1334 return _threadSynchronizer;
1335}

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

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

◆ updateDisplayConfig

- (void) updateDisplayConfig
implementation

Definition at line 483 of file FlutterEngine.mm.

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

◆ updateDisplayConfig:

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

Definition at line 483 of file FlutterEngine.mm.

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

◆ 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}

◆ updateWindowMetricsForViewController:

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

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

Definition at line 483 of file FlutterEngine.mm.

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

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

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

◆ viewControllerViewDidLoad:

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

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

Definition at line 483 of file FlutterEngine.mm.

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

◆ windowDidChangeScreen:

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

Definition at line 483 of file FlutterEngine.mm.

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

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

Provided by category FlutterEngine().

Definition at line 106 of file FlutterEngine.mm.

◆ initialRoute

- (NSString*) initialRoute
readwritenonatomiccopyimplementation

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

Definition at line 104 of file FlutterEngine.mm.

◆ pluginPublications

- (NSMutableDictionary*) pluginPublications
readnonatomicassignimplementation

Provided by category FlutterEngine().

Definition at line 101 of file FlutterEngine.mm.

◆ pluginRegistrars

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

All registrars returned from registrarForPlugin:

Provided by category FlutterEngine().

Definition at line 110 of file FlutterEngine.mm.

◆ registrars

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

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

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.

Provided by category FlutterEngine().

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: