diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index ed501e59fb9ec..c5f3b8d9accf0 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -296,8 +296,6 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI { threadLabel.UTF8String, // label shell::ThreadHost::Type::UI | shell::ThreadHost::Type::GPU | shell::ThreadHost::Type::IO}; - bool embedded_views_preview_enabled = [[[NSBundle mainBundle] - objectForInfoDictionaryKey:@(shell::kEmbeddedViewsPreview)] boolValue]; // Lambda captures by pointers to ObjC objects are fine here because the // create call is // synchronous. @@ -310,7 +308,7 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI { return std::make_unique(shell.GetTaskRunners()); }; - if (embedded_views_preview_enabled) { + if (shell::IsIosEmbeddedViewsPreviewEnabled()) { // Embedded views requires the gpu and the platform views to be the same. // The plan is to eventually dynamically merge the threads when there's a // platform view in the layer tree. diff --git a/shell/platform/darwin/ios/ios_surface.h b/shell/platform/darwin/ios/ios_surface.h index 660844d318202..1fc6a4218dc75 100644 --- a/shell/platform/darwin/ios/ios_surface.h +++ b/shell/platform/darwin/ios/ios_surface.h @@ -15,8 +15,9 @@ namespace shell { -// The name of the Info.plist flag to enable the embedded iOS views preview. -const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview"; +// Returns true if the app explicitly specified to use the iOS view embedding +// mechanism which is still in a release preview. +bool IsIosEmbeddedViewsPreviewEnabled(); class IOSSurface { public: diff --git a/shell/platform/darwin/ios/ios_surface.mm b/shell/platform/darwin/ios/ios_surface.mm index e4f79576534c6..f9d2d4cfbd500 100644 --- a/shell/platform/darwin/ios/ios_surface.mm +++ b/shell/platform/darwin/ios/ios_surface.mm @@ -11,6 +11,13 @@ namespace shell { +// The name of the Info.plist flag to enable the embedded iOS views preview. +const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview"; + +bool IsIosEmbeddedViewsPreviewEnabled() { + return [[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]; +} + IOSSurface::IOSSurface(FlutterPlatformViewsController* platform_views_controller) : platform_views_controller_(platform_views_controller) {} diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index 3a5315a261713..236b05dacae05 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -75,7 +75,7 @@ } flow::ExternalViewEmbedder* IOSSurfaceGL::GetExternalViewEmbedder() { - if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) { + if (IsIosEmbeddedViewsPreviewEnabled()) { return this; } else { return nullptr; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 3252b3e1cd418..a1017439c0057 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -127,7 +127,7 @@ } flow::ExternalViewEmbedder* IOSSurfaceSoftware::GetExternalViewEmbedder() { - if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) { + if (IsIosEmbeddedViewsPreviewEnabled()) { return this; } else { return nullptr;