13 #include "flutter/common/constants.h"
14 #include "flutter/fml/logging.h"
17 #include "flutter/shell/platform/embedder/embedder.h"
19 #import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
21 #import "flutter/shell/platform/darwin/macos/InternalFlutterSwift/InternalFlutterSwift.h"
37 #import <CoreVideo/CoreVideo.h>
38 #import <IOSurface/IOSurface.h>
46 using flutter::kFlutterImplicitViewId;
53 FlutterLocale flutterLocale = {};
54 flutterLocale.struct_size =
sizeof(FlutterLocale);
55 flutterLocale.language_code = [[locale objectForKey:NSLocaleLanguageCode] UTF8String];
56 flutterLocale.country_code = [[locale objectForKey:NSLocaleCountryCode] UTF8String];
57 flutterLocale.script_code = [[locale objectForKey:NSLocaleScriptCode] UTF8String];
58 flutterLocale.variant_code = [[locale objectForKey:NSLocaleVariantCode] UTF8String];
64 @"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification";
76 - (instancetype)initWithConnection:(NSNumber*)connection
85 - (instancetype)initWithConnection:(NSNumber*)connection
88 NSAssert(
self,
@"Super init cannot be nil");
110 @property(nonatomic, strong) NSMutableArray<NSNumber*>* isResponseValid;
115 @property(nonatomic, strong) NSPointerArray* pluginAppDelegates;
120 @property(nonatomic, readonly)
121 NSMutableDictionary<NSString*, FlutterEngineRegistrar*>* pluginRegistrars;
148 - (void)shutDownIfNeeded;
153 - (void)sendUserLocales;
158 - (void)engineCallbackOnPlatformMessage:(const FlutterPlatformMessage*)message;
164 - (void)postMainThreadTask:(FlutterTask)task targetTimeInNanoseconds:(uint64_t)targetTime;
170 - (void)loadAOTData:(NSString*)assetsDir;
175 - (void)setUpPlatformViewChannel;
180 - (void)setUpAccessibilityChannel;
199 _acceptingRequests = NO;
201 _terminator = terminator ? terminator : ^(
id sender) {
204 [[NSApplication sharedApplication] terminate:sender];
206 id<NSApplicationDelegate> appDelegate = [[NSApplication sharedApplication] delegate];
207 if ([appDelegate respondsToSelector:
@selector(setTerminationHandler:)]) {
209 flutterAppDelegate.terminationHandler =
self;
216 - (void)handleRequestAppExitMethodCall:(NSDictionary<NSString*,
id>*)arguments
218 NSString* type = arguments[@"type"];
224 FlutterAppExitType exitType =
225 [type isEqualTo:@"cancelable"] ? kFlutterAppExitTypeCancelable : kFlutterAppExitTypeRequired;
227 [
self requestApplicationTermination:[NSApplication sharedApplication]
234 - (void)requestApplicationTermination:(
id)sender
235 exitType:(FlutterAppExitType)type
237 _shouldTerminate = YES;
238 if (![
self acceptingRequests]) {
241 type = kFlutterAppExitTypeRequired;
244 case kFlutterAppExitTypeCancelable: {
248 [_engine sendOnChannel:kFlutterPlatformChannel
249 message:[codec encodeMethodCall:methodCall]
250 binaryReply:^(NSData* _Nullable reply) {
251 NSAssert(_terminator, @"terminator shouldn't be nil");
252 id decoded_reply = [codec decodeEnvelope:reply];
253 if ([decoded_reply isKindOfClass:[
FlutterError class]]) {
255 NSLog(@"Method call returned error[%@]: %@ %@", [error code], [error message],
260 if (![decoded_reply isKindOfClass:[NSDictionary class]]) {
261 NSLog(@"Call to System.requestAppExit returned an unexpected object: %@",
266 NSDictionary* replyArgs = (NSDictionary*)decoded_reply;
267 if ([replyArgs[@"response"] isEqual:@"exit"]) {
269 } else if ([replyArgs[@"response"] isEqual:@"cancel"]) {
270 _shouldTerminate = NO;
278 case kFlutterAppExitTypeRequired:
279 NSAssert(
_terminator,
@"terminator shouldn't be nil");
292 return [[NSPasteboard generalPasteboard] clearContents];
295 - (NSString*)stringForType:(NSPasteboardType)dataType {
296 return [[NSPasteboard generalPasteboard] stringForType:dataType];
299 - (BOOL)setString:(nonnull NSString*)string forType:(nonnull NSPasteboardType)dataType {
300 return [[NSPasteboard generalPasteboard] setString:string forType:dataType];
311 - (instancetype)initWithPlugin:(nonnull NSString*)pluginKey
325 NSString* _pluginKey;
331 - (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(
FlutterEngine*)flutterEngine {
334 _pluginKey = [pluginKey copy];
336 _publishedValue = [NSNull null];
341 #pragma mark - FlutterPluginRegistrar
343 - (int64_t)engineIdentifier {
356 return [
self viewForIdentifier:kFlutterImplicitViewId];
361 if (controller == nil) {
364 if (!controller.viewLoaded) {
365 [controller loadView];
367 return controller.flutterView;
370 - (NSViewController*)viewController {
371 return [_flutterEngine viewControllerForIdentifier:kFlutterImplicitViewId];
374 - (void)addMethodCallDelegate:(nonnull
id<
FlutterPlugin>)delegate
382 id<NSApplicationDelegate> appDelegate = [[NSApplication sharedApplication] delegate];
384 id<FlutterAppLifecycleProvider> lifeCycleProvider =
385 static_cast<id<FlutterAppLifecycleProvider>
>(appDelegate);
386 [lifeCycleProvider addApplicationLifecycleDelegate:delegate];
387 [_flutterEngine.pluginAppDelegates addPointer:(__bridge void*)delegate];
392 withId:(nonnull NSString*)factoryId {
393 [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId];
396 - (void)publish:(NSObject*)value {
397 _publishedValue = value;
400 - (nullable NSObject*)valuePublishedByPlugin:(NSString*)pluginKey {
401 return [_flutterEngine valuePublishedByPlugin:pluginKey];
404 - (NSString*)lookupKeyForAsset:(NSString*)asset {
408 - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
415 #pragma mark - Static methods provided to engine configuration
419 [engine engineCallbackOnPlatformMessage:message];
515 - (instancetype)initWithName:(NSString*)labelPrefix project:(
FlutterDartProject*)project {
516 return [
self initWithName:labelPrefix project:project allowHeadlessExecution:YES];
521 static void SetThreadPriority(FlutterThreadPriority priority) {
522 if (priority == kDisplay || priority == kRaster) {
523 pthread_t thread = pthread_self();
526 if (!pthread_getschedparam(thread, &policy, ¶m)) {
528 pthread_setschedparam(thread, policy, ¶m);
530 pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
534 - (instancetype)initWithName:(NSString*)labelPrefix
536 allowHeadlessExecution:(BOOL)allowHeadlessExecution {
538 NSAssert(
self,
@"Super init cannot be nil");
540 [FlutterRunLoop ensureMainLoopInitialized];
547 _pluginAppDelegates = [NSPointerArray weakObjectsPointerArray];
548 _pluginRegistrars = [[NSMutableDictionary alloc] init];
551 _semanticsEnabled = NO;
553 _isResponseValid = [[NSMutableArray alloc] initWithCapacity:1];
554 [_isResponseValid addObject:@YES];
560 _embedderAPI.struct_size =
sizeof(FlutterEngineProcTable);
561 FlutterEngineGetProcAddresses(&_embedderAPI);
566 NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
567 [notificationCenter addObserver:self
568 selector:@selector(sendUserLocales)
569 name:NSCurrentLocaleDidChangeNotification
579 [
self setUpPlatformViewChannel];
584 [
self setUpAccessibilityChannel];
585 [
self setUpNotificationCenterListeners];
586 id<NSApplicationDelegate> appDelegate = [[NSApplication sharedApplication] delegate];
590 id<FlutterAppLifecycleProvider> lifecycleProvider =
591 static_cast<id<FlutterAppLifecycleProvider>
>(appDelegate);
592 [lifecycleProvider addApplicationLifecycleDelegate:self];
594 _terminationHandler = nil;
603 id<NSApplicationDelegate> appDelegate = [[NSApplication sharedApplication] delegate];
605 id<FlutterAppLifecycleProvider> lifecycleProvider =
606 static_cast<id<FlutterAppLifecycleProvider>
>(appDelegate);
607 [lifecycleProvider removeApplicationLifecycleDelegate:self];
612 for (id<FlutterAppLifecycleDelegate> delegate in _pluginAppDelegates) {
614 [lifecycleProvider removeApplicationLifecycleDelegate:delegate];
620 for (NSString* pluginName in _pluginRegistrars) {
621 [_pluginRegistrars[pluginName] publish:[NSNull null]];
623 @
synchronized(_isResponseValid) {
624 [_isResponseValid removeAllObjects];
625 [_isResponseValid addObject:@NO];
627 [
self shutDownEngine];
629 _embedderAPI.CollectAOTData(
_aotData);
633 - (FlutterTaskRunnerDescription)createPlatformThreadTaskDescription {
634 static size_t sTaskRunnerIdentifiers = 0;
635 FlutterTaskRunnerDescription cocoa_task_runner_description = {
636 .struct_size =
sizeof(FlutterTaskRunnerDescription),
638 .
user_data = (__bridge_retained
void*)
self,
639 .runs_task_on_current_thread_callback = [](
void*
user_data) ->
bool {
640 return [[NSThread currentThread] isMainThread];
642 .post_task_callback = [](FlutterTask task, uint64_t target_time_nanos,
645 [engine postMainThreadTask:task targetTimeInNanoseconds:target_time_nanos];
647 .identifier = ++sTaskRunnerIdentifiers,
648 .destruction_callback =
655 return cocoa_task_runner_description;
658 - (void)onFocusChangeRequest:(const FlutterViewFocusChangeRequest*)request {
660 if (controller == nil) {
663 if (request->state == kFocused) {
664 [controller.flutterView.window makeFirstResponder:controller.flutterView];
668 - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
674 NSLog(
@"Attempted to run an engine with no view controller without headless mode enabled.");
678 [
self addInternalPlugins];
681 std::vector<const char*> argv = {[
self.executableName UTF8String]};
682 std::vector<std::string> switches =
self.switches;
685 if (std::find(switches.begin(), switches.end(),
"--enable-impeller=false") != switches.end()) {
687 }
else if (
_project.enableImpeller || std::find(switches.begin(), switches.end(),
688 "--enable-impeller=true") != switches.end()) {
689 switches.push_back(
"--enable-impeller=true");
692 if (std::find(switches.begin(), switches.end(),
"--enable-impeller=true") == switches.end()) {
693 FML_LOG(IMPORTANT) <<
"Using the Skia rendering backend (Metal).";
697 std::find(switches.begin(), switches.end(),
"--impeller-use-sdfs=true") != switches.end()) {
698 switches.push_back(
"--impeller-use-sdfs=true");
702 std::find(switches.begin(), switches.end(),
"--enable-flutter-gpu=true") != switches.end()) {
703 switches.push_back(
"--enable-flutter-gpu=true");
706 std::transform(switches.begin(), switches.end(), std::back_inserter(argv),
707 [](
const std::string& arg) ->
const char* { return arg.c_str(); });
709 std::vector<const char*> dartEntrypointArgs;
710 for (NSString* argument in [
_project dartEntrypointArguments]) {
711 dartEntrypointArgs.push_back([argument UTF8String]);
714 FlutterProjectArgs flutterArguments = {};
715 flutterArguments.struct_size =
sizeof(FlutterProjectArgs);
716 flutterArguments.assets_path =
_project.assetsPath.UTF8String;
717 flutterArguments.icu_data_path =
_project.ICUDataPath.UTF8String;
718 flutterArguments.command_line_argc =
static_cast<int>(argv.size());
719 flutterArguments.command_line_argv = argv.empty() ? nullptr : argv.data();
720 flutterArguments.platform_message_callback = (FlutterPlatformMessageCallback)
OnPlatformMessage;
721 flutterArguments.update_semantics_callback2 = [](
const FlutterSemanticsUpdate2* update,
727 [[engine viewControllerForIdentifier:kFlutterImplicitViewId] updateSemantics:update];
729 flutterArguments.custom_dart_entrypoint = entrypoint.UTF8String;
730 flutterArguments.shutdown_dart_vm_when_done =
true;
731 flutterArguments.dart_entrypoint_argc = dartEntrypointArgs.size();
732 flutterArguments.dart_entrypoint_argv = dartEntrypointArgs.data();
733 flutterArguments.root_isolate_create_callback =
_project.rootIsolateCreateCallback;
734 flutterArguments.log_message_callback = [](
const char* tag,
const char* message,
736 std::stringstream stream;
738 stream << tag <<
": ";
741 std::string log = stream.str();
742 [FlutterLogger logDirect:[NSString stringWithUTF8String:log.c_str()]];
745 flutterArguments.engine_id =
self.engineIdentifier;
746 BOOL enableWideGamut =
_project.enableWideGamut;
747 if (std::find(switches.begin(), switches.end(),
"--enable-impeller=false") != switches.end()) {
748 enableWideGamut = NO;
750 flutterArguments.enable_wide_gamut = enableWideGamut;
752 BOOL mergedPlatformUIThread = YES;
753 NSNumber* enableMergedPlatformUIThread =
754 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableMergedPlatformUIThread"];
755 if (enableMergedPlatformUIThread != nil) {
756 mergedPlatformUIThread = enableMergedPlatformUIThread.boolValue;
759 if (!mergedPlatformUIThread) {
760 NSLog(
@"Warning: Merged threads is disabled. Running Flutter without merged threads is "
761 "deprecated and will be unsupported in a future release.\n"
763 "To turn on merged threads, update your macos/Runner/Info.plist file:\n"
765 " <key>FLTEnableMergedPlatformUIThread</key>\n"
768 "If you disabled merged threads to work around an issue, please report it here: "
769 "https://github.com/flutter/flutter/issues/150525.");
775 FlutterTaskRunnerDescription platformTaskRunnerDescription =
776 [
self createPlatformThreadTaskDescription];
777 std::optional<FlutterTaskRunnerDescription> uiTaskRunnerDescription;
778 if (mergedPlatformUIThread) {
779 uiTaskRunnerDescription = [
self createPlatformThreadTaskDescription];
782 const FlutterCustomTaskRunners custom_task_runners = {
783 .struct_size =
sizeof(FlutterCustomTaskRunners),
784 .platform_task_runner = &platformTaskRunnerDescription,
785 .thread_priority_setter = SetThreadPriority,
786 .ui_task_runner = uiTaskRunnerDescription ? &uiTaskRunnerDescription.value() :
nullptr,
788 flutterArguments.custom_task_runners = &custom_task_runners;
790 [
self loadAOTData:_project.assetsPath];
792 flutterArguments.aot_data =
_aotData;
795 flutterArguments.compositor = [
self createFlutterCompositor];
797 flutterArguments.on_pre_engine_restart_callback = [](
void*
user_data) {
799 [engine engineCallbackOnPreEngineRestart];
802 flutterArguments.vsync_callback = [](
void*
user_data, intptr_t baton) {
804 [engine onVSync:baton];
807 flutterArguments.view_focus_change_request_callback =
808 [](
const FlutterViewFocusChangeRequest* request,
void*
user_data) {
810 [engine onFocusChangeRequest:request];
813 FlutterRendererConfig rendererConfig = [_renderer createRendererConfig];
814 FlutterEngineResult result = _embedderAPI.Initialize(
815 FLUTTER_ENGINE_VERSION, &rendererConfig, &flutterArguments, (__bridge
void*)(
self), &_engine);
816 if (result != kSuccess) {
817 NSLog(
@"Failed to initialize Flutter engine: error %d", result);
821 result = _embedderAPI.RunInitialized(_engine);
822 if (result != kSuccess) {
823 NSLog(
@"Failed to run an initialized engine: error %d", result);
827 [
self sendUserLocales];
830 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
832 while ((nextViewController = [viewControllerEnumerator nextObject])) {
833 [
self updateWindowMetricsForViewController:nextViewController];
836 [
self updateDisplayConfig];
839 [
self sendInitialSettings];
843 - (void)loadAOTData:(NSString*)assetsDir {
844 if (!_embedderAPI.RunsAOTCompiledDartCode()) {
848 BOOL isDirOut =
false;
849 NSFileManager* fileManager = [NSFileManager defaultManager];
853 NSString* elfPath = [NSString pathWithComponents:@[ assetsDir, @"app_elf_snapshot.so" ]];
855 if (![fileManager fileExistsAtPath:elfPath isDirectory:&isDirOut]) {
859 FlutterEngineAOTDataSource source = {};
860 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
861 source.elf_path = [elfPath cStringUsingEncoding:NSUTF8StringEncoding];
863 auto result = _embedderAPI.CreateAOTData(&source, &
_aotData);
864 if (result != kSuccess) {
865 NSLog(
@"Failed to load AOT data from: %@", elfPath);
872 NSAssert(controller != nil,
@"The controller must not be nil.");
874 NSAssert(controller.
engine == nil,
875 @"The FlutterViewController is unexpectedly attached to "
876 @"engine %@ before initialization.",
880 @"The requested view ID is occupied.");
881 [_viewControllers setObject:controller forKey:@(viewIdentifier)];
882 [controller setUpWithEngine:self viewIdentifier:viewIdentifier];
883 NSAssert(controller.
viewIdentifier == viewIdentifier,
@"Failed to assign view ID.");
887 NSAssert(controller.
attached,
@"The FlutterViewController should switch to the attached mode "
888 @"after it is added to a FlutterEngine.");
889 NSAssert(controller.
engine ==
self,
890 @"The FlutterViewController was added to %@, but its engine unexpectedly became %@.",
893 if (controller.viewLoaded) {
894 [
self viewControllerViewDidLoad:controller];
897 if (viewIdentifier != kFlutterImplicitViewId) {
900 FlutterWindowMetricsEvent metrics{
901 .struct_size =
sizeof(FlutterWindowMetricsEvent),
907 FlutterAddViewInfo info{.struct_size =
sizeof(FlutterAddViewInfo),
908 .view_id = viewIdentifier,
909 .view_metrics = &metrics,
911 .add_view_callback = [](
const FlutterAddViewResult* r) {
912 auto added =
reinterpret_cast<bool*
>(r->user_data);
916 _embedderAPI.AddView(_engine, &info);
919 NSLog(
@"Failed to add view with ID %llu", viewIdentifier);
929 block:^(CFTimeInterval timestamp, CFTimeInterval targetTimestamp,
932 uint64_t targetTimeNanos =
934 FlutterEngine* engine = weakSelf;
936 engine->_embedderAPI.OnVsync(_engine, baton, timeNanos, targetTimeNanos);
941 [_vsyncWaiters setObject:waiter forKey:@(viewController.viewIdentifier)];
946 if (viewIdentifier != kFlutterImplicitViewId) {
947 bool removed =
false;
948 FlutterRemoveViewInfo info;
949 info.struct_size =
sizeof(FlutterRemoveViewInfo);
950 info.view_id = viewIdentifier;
951 info.user_data = &removed;
955 info.remove_view_callback = [](
const FlutterRemoveViewResult* r) {
956 auto removed =
reinterpret_cast<bool*
>(r->user_data);
957 [FlutterRunLoop.mainRunLoop performBlock:^{
961 _embedderAPI.RemoveView(_engine, &info);
963 [[FlutterRunLoop mainRunLoop] pollFlutterMessagesOnce];
972 if (controller != nil) {
973 [controller detachFromEngine];
975 @"The FlutterViewController unexpectedly stays attached after being removed. "
976 @"In unit tests, this is likely because either the FlutterViewController or "
977 @"the FlutterEngine is mocked. Please subclass these classes instead.");
979 [_viewControllers removeObjectForKey:@(viewIdentifier)];
983 waiter = [_vsyncWaiters objectForKey:@(viewIdentifier)];
984 [_vsyncWaiters removeObjectForKey:@(viewIdentifier)];
989 - (void)shutDownIfNeeded {
991 [
self shutDownEngine];
997 NSAssert(controller == nil || controller.
viewIdentifier == viewIdentifier,
998 @"The stored controller has unexpected view ID.");
1004 [_viewControllers objectForKey:@(kFlutterImplicitViewId)];
1005 if (currentController == controller) {
1009 if (currentController == nil && controller != nil) {
1011 NSAssert(controller.
engine == nil,
1012 @"Failed to set view controller to the engine: "
1013 @"The given FlutterViewController is already attached to an engine %@. "
1014 @"If you wanted to create an FlutterViewController and set it to an existing engine, "
1015 @"you should use FlutterViewController#init(engine:, nibName, bundle:) instead.",
1017 [
self registerViewController:controller forIdentifier:kFlutterImplicitViewId];
1018 }
else if (currentController != nil && controller == nil) {
1019 NSAssert(currentController.
viewIdentifier == kFlutterImplicitViewId,
1020 @"The default controller has an unexpected ID %llu", currentController.
viewIdentifier);
1022 [
self deregisterViewControllerForIdentifier:kFlutterImplicitViewId];
1023 [
self shutDownIfNeeded];
1027 @"Failed to set view controller to the engine: "
1028 @"The engine already has an implicit view controller %@. "
1029 @"If you wanted to make the implicit view render in a different window, "
1030 @"you should attach the current view controller to the window instead.",
1036 return [
self viewControllerForIdentifier:kFlutterImplicitViewId];
1039 - (FlutterCompositor*)createFlutterCompositor {
1041 _compositor.struct_size =
sizeof(FlutterCompositor);
1044 _compositor.create_backing_store_callback = [](
const FlutterBackingStoreConfig* config,
1045 FlutterBackingStore* backing_store_out,
1049 config, backing_store_out);
1052 _compositor.collect_backing_store_callback = [](
const FlutterBackingStore* backing_store,
1056 _compositor.present_view_callback = [](
const FlutterPresentViewInfo* info) {
1058 ->Present(info->view_id, info->layers, info->layers_count);
1070 #pragma mark - Framework-internal methods
1076 NSAssert(
self.viewController == nil,
1077 @"The engine already has a view controller for the implicit view.");
1078 self.viewController = controller;
1083 [
self registerViewController:controller forIdentifier:viewIdentifier];
1087 - (void)enableMultiView {
1089 NSAssert(
self.viewController == nil,
1090 @"Multiview can only be enabled before adding any view controllers.");
1096 FlutterViewFocusEvent
event{
1097 .struct_size =
sizeof(FlutterViewFocusEvent),
1098 .view_id = viewIdentifier,
1100 .direction = kUndefined,
1102 _embedderAPI.SendViewFocusEvent(_engine, &event);
1106 FlutterViewFocusEvent
event{
1107 .struct_size =
sizeof(FlutterViewFocusEvent),
1108 .view_id = viewIdentifier,
1109 .state = kUnfocused,
1110 .direction = kUndefined,
1112 _embedderAPI.SendViewFocusEvent(_engine, &event);
1116 [
self deregisterViewControllerForIdentifier:viewController.viewIdentifier];
1117 [
self shutDownIfNeeded];
1121 return _engine !=
nullptr;
1124 - (void)updateDisplayConfig:(NSNotification*)notification {
1125 [
self updateDisplayConfig];
1128 - (NSArray<NSScreen*>*)screens {
1129 return [NSScreen screens];
1132 - (void)updateDisplayConfig {
1137 std::vector<FlutterEngineDisplay> displays;
1138 for (NSScreen* screen : [
self screens]) {
1139 CGDirectDisplayID displayID =
1140 static_cast<CGDirectDisplayID
>([screen.deviceDescription[@"NSScreenNumber"] integerValue]);
1142 double devicePixelRatio = screen.backingScaleFactor;
1143 FlutterEngineDisplay display;
1144 display.struct_size =
sizeof(display);
1145 display.display_id = displayID;
1146 display.single_display =
false;
1147 display.width =
static_cast<size_t>(screen.frame.size.width) * devicePixelRatio;
1148 display.height =
static_cast<size_t>(screen.frame.size.height) * devicePixelRatio;
1149 display.device_pixel_ratio = devicePixelRatio;
1151 CVDisplayLinkRef displayLinkRef = nil;
1152 CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &displayLinkRef);
1155 CVTime nominal = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLinkRef);
1156 if (!(nominal.flags & kCVTimeIsIndefinite)) {
1157 double refreshRate =
static_cast<double>(nominal.timeScale) / nominal.timeValue;
1158 display.refresh_rate = round(refreshRate);
1160 CVDisplayLinkRelease(displayLinkRef);
1162 display.refresh_rate = 0;
1165 displays.push_back(display);
1167 _embedderAPI.NotifyDisplayUpdate(_engine, kFlutterEngineDisplaysUpdateTypeStartup,
1168 displays.data(), displays.size());
1171 - (void)onSettingsChanged:(NSNotification*)notification {
1173 NSString* brightness =
1174 [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
1175 [_settingsChannel sendMessage:@{
1176 @"platformBrightness" : [brightness isEqualToString:@"Dark"] ? @"dark" : @"light",
1178 @"textScaleFactor" : @1.0,
1183 - (void)sendInitialSettings {
1185 [[NSDistributedNotificationCenter defaultCenter]
1187 selector:@selector(onSettingsChanged:)
1188 name:@"AppleInterfaceThemeChangedNotification"
1190 [
self onSettingsChanged:nil];
1193 - (FlutterEngineProcTable&)embedderAPI {
1194 return _embedderAPI;
1197 - (nonnull NSString*)executableName {
1198 return [[[NSProcessInfo processInfo] arguments] firstObject] ?:
@"Flutter";
1202 if (!_engine || !viewController || !viewController.viewLoaded) {
1205 NSAssert([
self viewControllerForIdentifier:viewController.
viewIdentifier] == viewController,
1206 @"The provided view controller is not attached to this engine.");
1208 CGRect scaledBounds = [view convertRectToBacking:view.bounds];
1209 CGSize scaledSize = scaledBounds.size;
1210 double pixelRatio = view.layer.contentsScale;
1211 auto displayId = [view.window.screen.deviceDescription[@"NSScreenNumber"] integerValue];
1212 FlutterWindowMetricsEvent windowMetricsEvent = {
1213 .struct_size =
sizeof(windowMetricsEvent),
1214 .width =
static_cast<size_t>(scaledSize.width),
1215 .height =
static_cast<size_t>(scaledSize.height),
1216 .pixel_ratio = pixelRatio,
1217 .left =
static_cast<size_t>(scaledBounds.origin.x),
1218 .top =
static_cast<size_t>(scaledBounds.origin.y),
1219 .display_id =
static_cast<uint64_t
>(displayId),
1223 CGSize maximumContentSize = [view convertSizeToBacking:view.maximumContentSize];
1224 CGSize minimumContentSize = [view convertSizeToBacking:view.minimumContentSize];
1225 windowMetricsEvent.has_constraints =
true;
1226 windowMetricsEvent.min_width_constraint =
static_cast<size_t>(minimumContentSize.width);
1227 windowMetricsEvent.min_height_constraint =
static_cast<size_t>(minimumContentSize.height);
1228 windowMetricsEvent.max_width_constraint =
static_cast<size_t>(maximumContentSize.width);
1229 windowMetricsEvent.max_height_constraint =
static_cast<size_t>(maximumContentSize.height);
1231 windowMetricsEvent.min_width_constraint =
static_cast<size_t>(scaledSize.width);
1232 windowMetricsEvent.min_height_constraint =
static_cast<size_t>(scaledSize.height);
1233 windowMetricsEvent.max_width_constraint =
static_cast<size_t>(scaledSize.width);
1234 windowMetricsEvent.max_height_constraint =
static_cast<size_t>(scaledSize.height);
1236 _embedderAPI.SendWindowMetricsEvent(_engine, &windowMetricsEvent);
1239 - (void)sendPointerEvent:(const FlutterPointerEvent&)event {
1240 _embedderAPI.SendPointerEvent(_engine, &event, 1);
1244 - (void)setSemanticsEnabled:(BOOL)enabled {
1245 if (_semanticsEnabled == enabled) {
1248 _semanticsEnabled = enabled;
1251 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1253 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1254 [nextViewController notifySemanticsEnabledChanged];
1257 _embedderAPI.UpdateSemanticsEnabled(_engine, _semanticsEnabled);
1260 - (void)dispatchSemanticsAction:(FlutterSemanticsAction)action
1261 toTarget:(uint16_t)target
1262 withData:(fml::MallocMapping)data {
1263 _embedderAPI.DispatchSemanticsAction(_engine, target, action, data.GetMapping(), data.GetSize());
1270 #pragma mark - Private methods
1272 - (void)sendUserLocales {
1273 if (!
self.running) {
1278 NSMutableArray<NSLocale*>* locales = [NSMutableArray array];
1279 std::vector<FlutterLocale> flutterLocales;
1280 flutterLocales.reserve(locales.count);
1281 for (NSString* localeID in [NSLocale preferredLanguages]) {
1282 NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:localeID];
1283 [locales addObject:locale];
1287 std::vector<const FlutterLocale*> flutterLocaleList;
1288 flutterLocaleList.reserve(flutterLocales.size());
1289 std::transform(flutterLocales.begin(), flutterLocales.end(),
1290 std::back_inserter(flutterLocaleList),
1291 [](
const auto& arg) ->
const auto* { return &arg; });
1292 _embedderAPI.UpdateLocales(_engine, flutterLocaleList.data(), flutterLocaleList.size());
1295 - (void)engineCallbackOnPlatformMessage:(const FlutterPlatformMessage*)message {
1296 NSData* messageData = nil;
1297 if (message->message_size > 0) {
1298 messageData = [NSData dataWithBytesNoCopy:(void*)message->message
1299 length:message->message_size
1302 NSString* channel = @(message->channel);
1303 __block
const FlutterPlatformMessageResponseHandle* responseHandle = message->response_handle;
1305 NSMutableArray* isResponseValid =
self.isResponseValid;
1306 FlutterEngineSendPlatformMessageResponseFnPtr sendPlatformMessageResponse =
1307 _embedderAPI.SendPlatformMessageResponse;
1309 @
synchronized(isResponseValid) {
1310 if (![isResponseValid[0] boolValue]) {
1314 if (responseHandle) {
1315 sendPlatformMessageResponse(weakSelf->_engine, responseHandle,
1316 static_cast<const uint8_t*
>(response.bytes), response.length);
1317 responseHandle = NULL;
1319 NSLog(
@"Error: Message responses can be sent only once. Ignoring duplicate response "
1328 handlerInfo.
handler(messageData, binaryResponseHandler);
1330 binaryResponseHandler(nil);
1334 - (void)engineCallbackOnPreEngineRestart {
1335 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1337 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1340 [_windowController closeAllWindows];
1341 [_platformViewController reset];
1347 - (void)onVSync:(uintptr_t)baton {
1352 [_vsyncWaiters objectForKey:[_vsyncWaiters.keyEnumerator nextObject]];
1353 if (waiter != nil) {
1359 self.embedderAPI.OnVsync(_engine, baton, 0, 0);
1362 if ([NSThread isMainThread]) {
1365 [FlutterRunLoop.mainRunLoop performBlock:block];
1372 - (void)shutDownEngine {
1373 if (_engine ==
nullptr) {
1377 FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
1378 if (result != kSuccess) {
1379 NSLog(
@"Could not de-initialize the Flutter engine: error %d", result);
1382 result = _embedderAPI.Shutdown(_engine);
1383 if (result != kSuccess) {
1384 NSLog(
@"Failed to shut down Flutter engine: error %d", result);
1389 - (int64_t)engineIdentifier {
1390 return reinterpret_cast<int64_t
>((__bridge
void*)
self);
1394 NSAssert([[NSThread currentThread] isMainThread],
@"Must be called on the main thread.");
1395 return (__bridge
FlutterEngine*)
reinterpret_cast<void*
>(identifier);
1398 - (void)setUpPlatformViewChannel {
1405 [_platformViewsChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1406 [[weakSelf platformViewController] handleMethodCall:call result:result];
1410 - (void)setUpAccessibilityChannel {
1416 [_accessibilityChannel setMessageHandler:^(id message, FlutterReply reply) {
1417 [weakSelf handleAccessibilityEvent:message];
1420 - (void)setUpNotificationCenterListeners {
1421 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
1423 [center addObserver:self
1424 selector:@selector(onAccessibilityStatusChanged:)
1425 name:kEnhancedUserInterfaceNotification
1427 [center addObserver:self
1428 selector:@selector(applicationWillTerminate:)
1429 name:NSApplicationWillTerminateNotification
1431 [center addObserver:self
1432 selector:@selector(windowDidChangeScreen:)
1433 name:NSWindowDidChangeScreenNotification
1435 [center addObserver:self
1436 selector:@selector(updateDisplayConfig:)
1437 name:NSApplicationDidChangeScreenParametersNotification
1441 - (void)addInternalPlugins {
1455 [_platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1456 [weakSelf handleMethodCall:call result:result];
1463 [_screenshotChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
1467 message:@"Engine deallocated."
1471 FlutterViewController* viewController =
1472 [strongSelf viewControllerForIdentifier:flutter::kFlutterImplicitViewId];
1473 if (!viewController) {
1475 message:@"No view controller."
1479 NSArray<FlutterSurface*>* frontSurfaces =
1480 viewController.flutterView.surfaceManager.frontSurfaces;
1481 if (frontSurfaces.count == 0) {
1488 FlutterSurface* surface = frontSurfaces.firstObject;
1489 IOSurfaceRef ioSurface = surface.ioSurface;
1491 size_t width = IOSurfaceGetWidth(ioSurface);
1492 size_t height = IOSurfaceGetHeight(ioSurface);
1493 size_t bytesPerRow = IOSurfaceGetBytesPerRow(ioSurface);
1494 size_t bytesPerElement = IOSurfaceGetBytesPerElement(ioSurface);
1495 uint32_t pixelFormat = (uint32_t)IOSurfaceGetPixelFormat(ioSurface);
1497 NSString* formatString;
1498 switch (pixelFormat) {
1499 case kCVPixelFormatType_40ARGBLEWideGamut:
1500 formatString = @"MTLPixelFormatBGRA10_XR";
1502 case kCVPixelFormatType_32BGRA:
1503 formatString = @"MTLPixelFormatBGRA8Unorm";
1506 formatString = [NSString stringWithFormat:@"Unknown(%u)", pixelFormat];
1510 IOSurfaceLock(ioSurface, kIOSurfaceLockReadOnly, nil);
1511 void* baseAddress = IOSurfaceGetBaseAddress(ioSurface);
1514 size_t packedBytesPerRow = width * bytesPerElement;
1515 NSMutableData* packedData = [NSMutableData dataWithLength:packedBytesPerRow * height];
1516 uint8_t* dest = (uint8_t*)packedData.mutableBytes;
1517 for (size_t row = 0; row < height; row++) {
1518 memcpy(dest + row * packedBytesPerRow, (uint8_t*)baseAddress + row * bytesPerRow,
1522 IOSurfaceUnlock(ioSurface, kIOSurfaceLockReadOnly, nil);
1533 - (void)didUpdateMouseCursor:(NSCursor*)cursor {
1537 [_lastViewWithPointerEvent didUpdateMouseCursor:cursor];
1540 - (void)applicationWillTerminate:(NSNotification*)notification {
1541 [
self shutDownEngine];
1544 - (void)windowDidChangeScreen:(NSNotification*)notification {
1547 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1549 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1550 [
self updateWindowMetricsForViewController:nextViewController];
1551 [nextViewController updateWideGamutForScreen];
1555 - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
1556 BOOL enabled = [notification.userInfo[kEnhancedUserInterfaceKey] boolValue];
1557 NSEnumerator* viewControllerEnumerator = [_viewControllers objectEnumerator];
1559 while ((nextViewController = [viewControllerEnumerator nextObject])) {
1563 self.semanticsEnabled = enabled;
1565 - (void)handleAccessibilityEvent:(NSDictionary<NSString*,
id>*)annotatedEvent {
1566 NSString* type = annotatedEvent[@"type"];
1567 if ([type isEqualToString:
@"announce"]) {
1568 NSString* message = annotatedEvent[@"data"][@"message"];
1569 NSNumber* assertiveness = annotatedEvent[@"data"][@"assertiveness"];
1570 if (message == nil) {
1574 NSAccessibilityPriorityLevel priority = [assertiveness isEqualToNumber:@1]
1575 ? NSAccessibilityPriorityHigh
1576 : NSAccessibilityPriorityMedium;
1578 [
self announceAccessibilityMessage:message withPriority:priority];
1582 - (void)announceAccessibilityMessage:(NSString*)message
1583 withPriority:(NSAccessibilityPriorityLevel)priority {
1584 NSAccessibilityPostNotificationWithUserInfo(
1585 [
self viewControllerForIdentifier:kFlutterImplicitViewId].flutterView,
1586 NSAccessibilityAnnouncementRequestedNotification,
1587 @{NSAccessibilityAnnouncementKey : message, NSAccessibilityPriorityKey : @(priority)});
1590 if ([call.
method isEqualToString:
@"SystemNavigator.pop"]) {
1591 [[NSApplication sharedApplication] terminate:self];
1593 }
else if ([call.
method isEqualToString:
@"SystemSound.play"]) {
1594 [
self playSystemSound:call.arguments];
1596 }
else if ([call.
method isEqualToString:
@"Clipboard.getData"]) {
1597 result([
self getClipboardData:call.
arguments]);
1598 }
else if ([call.
method isEqualToString:
@"Clipboard.setData"]) {
1599 [
self setClipboardData:call.arguments];
1601 }
else if ([call.
method isEqualToString:
@"Clipboard.hasStrings"]) {
1602 result(@{
@"value" : @([
self clipboardHasStrings])});
1603 }
else if ([call.
method isEqualToString:
@"System.exitApplication"]) {
1604 if ([
self terminationHandler] == nil) {
1609 [NSApp terminate:self];
1612 [[
self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result];
1614 }
else if ([call.
method isEqualToString:
@"System.initializationComplete"]) {
1615 if ([
self terminationHandler] != nil) {
1616 [
self terminationHandler].acceptingRequests = YES;
1624 - (void)playSystemSound:(NSString*)soundType {
1625 if ([soundType isEqualToString:
@"SystemSoundType.alert"]) {
1630 - (NSDictionary*)getClipboardData:(NSString*)format {
1632 NSString* stringInPasteboard = [
self.pasteboard stringForType:NSPasteboardTypeString];
1633 return stringInPasteboard == nil ? nil : @{
@"text" : stringInPasteboard};
1638 - (void)setClipboardData:(NSDictionary*)data {
1639 NSString* text = data[@"text"];
1640 [
self.pasteboard clearContents];
1641 if (text && ![text isEqual:[NSNull
null]]) {
1642 [
self.pasteboard setString:text forType:NSPasteboardTypeString];
1646 - (BOOL)clipboardHasStrings {
1647 return [
self.pasteboard stringForType:NSPasteboardTypeString].length > 0;
1650 - (std::vector<std::string>)switches {
1654 #pragma mark - FlutterAppLifecycleDelegate
1657 NSString* nextState =
1658 [[NSString alloc] initWithCString:flutter::AppLifecycleStateToString(state)];
1659 [
self sendOnChannel:kFlutterLifecycleChannel
1660 message:[nextState dataUsingEncoding:NSUTF8StringEncoding]];
1667 - (void)handleWillBecomeActive:(NSNotification*)notification {
1673 for (NSWindow* window in [NSApplication sharedApplication].windows) {
1674 if (window.isVisible) {
1679 [
self setApplicationState:_visible ? flutter::AppLifecycleState::kResumed
1680 : flutter::AppLifecycleState::kHidden];
1687 - (void)handleWillResignActive:(NSNotification*)notification {
1690 [
self setApplicationState:flutter::AppLifecycleState::kHidden];
1692 [
self setApplicationState:flutter::AppLifecycleState::kInactive];
1700 - (void)handleDidChangeOcclusionState:(NSNotification*)notification {
1701 NSApplicationOcclusionState occlusionState = [[NSApplication sharedApplication] occlusionState];
1702 if (occlusionState & NSApplicationOcclusionStateVisible) {
1705 [
self setApplicationState:flutter::AppLifecycleState::kResumed];
1707 [
self setApplicationState:flutter::AppLifecycleState::kInactive];
1711 [
self setApplicationState:flutter::AppLifecycleState::kHidden];
1715 #pragma mark - FlutterBinaryMessenger
1717 - (void)sendOnChannel:(nonnull NSString*)channel message:(nullable NSData*)message {
1718 [
self sendOnChannel:channel message:message binaryReply:nil];
1721 - (void)sendOnChannel:(NSString*)channel
1722 message:(NSData* _Nullable)message
1724 FlutterPlatformMessageResponseHandle* response_handle =
nullptr;
1729 auto captures = std::make_unique<Captures>();
1730 captures->reply = callback;
1731 auto message_reply = [](
const uint8_t* data,
size_t data_size,
void*
user_data) {
1732 auto captures =
reinterpret_cast<Captures*
>(
user_data);
1733 NSData* reply_data = nil;
1734 if (data !=
nullptr && data_size > 0) {
1735 reply_data = [NSData dataWithBytes:static_cast<const void*>(data) length:data_size];
1737 captures->reply(reply_data);
1741 FlutterEngineResult create_result = _embedderAPI.PlatformMessageCreateResponseHandle(
1742 _engine, message_reply, captures.get(), &response_handle);
1743 if (create_result != kSuccess) {
1744 NSLog(
@"Failed to create a FlutterPlatformMessageResponseHandle (%d)", create_result);
1750 FlutterPlatformMessage platformMessage = {
1751 .struct_size =
sizeof(FlutterPlatformMessage),
1752 .channel = [channel UTF8String],
1753 .message =
static_cast<const uint8_t*
>(message.bytes),
1754 .message_size = message.length,
1755 .response_handle = response_handle,
1758 FlutterEngineResult message_result = _embedderAPI.SendPlatformMessage(_engine, &platformMessage);
1759 if (message_result != kSuccess) {
1760 NSLog(
@"Failed to send message to Flutter engine on channel '%@' (%d).", channel,
1764 if (response_handle !=
nullptr) {
1765 FlutterEngineResult release_result =
1766 _embedderAPI.PlatformMessageReleaseResponseHandle(_engine, response_handle);
1767 if (release_result != kSuccess) {
1768 NSLog(
@"Failed to release the response handle (%d).", release_result);
1774 binaryMessageHandler:
1779 handler:[handler copy]];
1786 NSString* foundChannel = nil;
1789 if ([handlerInfo.
connection isEqual:@(connection)]) {
1795 [_messengerHandlers removeObjectForKey:foundChannel];
1799 #pragma mark - FlutterPluginRegistry
1802 id<FlutterPluginRegistrar> registrar =
self.pluginRegistrars[pluginName];
1806 self.pluginRegistrars[pluginName] = registrarImpl;
1807 registrar = registrarImpl;
1812 - (nullable NSObject*)valuePublishedByPlugin:(NSString*)pluginName {
1816 #pragma mark - FlutterTextureRegistrar
1819 return [_renderer registerTexture:texture];
1822 - (BOOL)registerTextureWithID:(int64_t)textureId {
1823 return _embedderAPI.RegisterExternalTexture(_engine, textureId) == kSuccess;
1826 - (void)textureFrameAvailable:(int64_t)textureID {
1827 [_renderer textureFrameAvailable:textureID];
1830 - (BOOL)markTextureFrameAvailable:(int64_t)textureID {
1831 return _embedderAPI.MarkExternalTextureFrameAvailable(_engine, textureID) == kSuccess;
1834 - (void)unregisterTexture:(int64_t)textureID {
1835 [_renderer unregisterTexture:textureID];
1838 - (BOOL)unregisterTextureWithID:(int64_t)textureID {
1839 return _embedderAPI.UnregisterExternalTexture(_engine, textureID) == kSuccess;
1842 #pragma mark - Task runner integration
1844 - (void)postMainThreadTask:(FlutterTask)task targetTimeInNanoseconds:(uint64_t)targetTime {
1847 const auto engine_time = _embedderAPI.GetCurrentTime();
1848 [FlutterRunLoop.mainRunLoop
1849 performAfterDelay:(targetTime - (double)engine_time) / NSEC_PER_SEC
1852 if (self != nil && self->_engine != nil) {
1853 auto result = _embedderAPI.RunTask(self->_engine, &task);
1854 if (result != kSuccess) {
1855 NSLog(@"Could not post a task to the Flutter engine.");
1862 - (
flutter::FlutterCompositor*)macOSCompositor {
1866 #pragma mark - FlutterKeyboardManagerDelegate
1871 - (void)sendKeyEvent:(const FlutterKeyEvent&)event
1872 callback:(FlutterKeyEventCallback)callback
1873 userData:(
void*)userData {
1874 _embedderAPI.SendKeyEvent(_engine, &event, callback, userData);
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
int64_t FlutterBinaryMessengerConnection
void(^ FlutterResult)(id _Nullable result)
FLUTTER_DARWIN_EXPORT NSObject const * FlutterMethodNotImplemented
FlutterBinaryMessengerConnection _connection
FlutterMethodChannel * _platformViewsChannel
_FlutterEngineAOTData * _aotData
std::unique_ptr< flutter::FlutterCompositor > _macOSCompositor
static const int kMainThreadPriority
static void OnPlatformMessage(const FlutterPlatformMessage *message, void *user_data)
FlutterPlatformViewController * _platformViewController
FlutterBasicMessageChannel * _accessibilityChannel
FlutterBasicMessageChannel * _settingsChannel
static FlutterLocale FlutterLocaleFromNSLocale(NSLocale *locale)
BOOL _allowHeadlessExecution
NSMutableDictionary< NSString *, FlutterEngineHandlerInfo * > * _messengerHandlers
FlutterBinaryMessengerConnection _currentMessengerConnection
FlutterMethodChannel * _platformChannel
NSString *const kFlutterLifecycleChannel
static NSString *const kEnhancedUserInterfaceNotification
The private notification for voice over.
NSMapTable< NSNumber *, FlutterVSyncWaiter * > * _vsyncWaiters
FlutterViewIdentifier _nextViewIdentifier
NSString *const kFlutterPlatformChannel
FlutterMethodChannel * _screenshotChannel
FlutterTextInputPlugin * _textInputPlugin
FlutterDartProject * _project
NSMapTable * _viewControllers
FlutterCompositor _compositor
__weak FlutterView * _lastViewWithPointerEvent
FlutterKeyboardManager * _keyboardManager
FlutterWindowController * _windowController
FlutterTerminationCallback _terminator
constexpr char kTextPlainFormat[]
Clipboard plain text format.
__weak FlutterEngine * _flutterEngine
FlutterBinaryMessengerRelay * _binaryMessenger
static NSString *const kEnhancedUserInterfaceKey
NSString *const kFlutterSettingsChannel
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterTerminationCallback)(id _Nullable sender)
int64_t FlutterViewIdentifier
NSString * lookupKeyForAsset:fromPackage:(NSString *asset,[fromPackage] NSString *package)
NSString * lookupKeyForAsset:(NSString *asset)
NSInteger clearContents()
instancetype messageChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMessageCodec > *codec)
instancetype displayLinkWithView:(NSView *view)
FlutterBinaryMessageHandler handler
id< FlutterBinaryMessenger > binaryMessenger
NSObject * publishedValue
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void setMethodCallHandler:(FlutterMethodCallHandler _Nullable handler)
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)
instancetype typedDataWithBytes:(NSData *data)
Converts between the time representation used by Flutter Engine and CAMediaTime.
uint64_t CAMediaTimeToEngineTime:(CFTimeInterval time)
void waitForVSync:(uintptr_t baton)
void onPreEngineRestart()
FlutterViewIdentifier viewIdentifier
void onAccessibilityStatusChanged:(BOOL enabled)
std::vector< std::string > GetSwitchesFromEnvironment()
instancetype sharedInstance()
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)