@@ -105,8 +105,6 @@ @interface FlutterEngine () <FlutterIndirectScribbleDelegate,
105105@property (nonatomic , readonly , assign ) BOOL allowHeadlessExecution;
106106@property (nonatomic , readonly , assign ) BOOL restorationEnabled;
107107
108- @property (nonatomic , strong ) FlutterPlatformViewsController* platformViewsController;
109-
110108// Maintains a dictionary of plugin names that have registered with the engine. Used by
111109// FlutterEngineRegistrar to implement a FlutterPluginRegistrar.
112110@property (nonatomic , readonly ) NSMutableDictionary * pluginPublications;
@@ -152,6 +150,7 @@ @implementation FlutterEngine {
152150 std::shared_ptr<flutter::ThreadHost> _threadHost;
153151 std::unique_ptr<flutter::Shell> _shell;
154152
153+ std::shared_ptr<flutter::PlatformViewsController> _platformViewsController;
155154 flutter::IOSRenderingAPI _renderingApi;
156155 std::shared_ptr<flutter::SamplingProfiler> _profiler;
157156
@@ -212,7 +211,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix
212211
213212 _pluginPublications = [[NSMutableDictionary alloc ] init ];
214213 _registrars = [[NSMutableDictionary alloc ] init ];
215- [self recreatePlatformViewsController ];
214+ [self recreatePlatformViewController ];
216215 _binaryMessenger = [[FlutterBinaryMessengerRelay alloc ] initWithParent: self ];
217216 _textureRegistry = [[FlutterTextureRegistryRelay alloc ] initWithParent: self ];
218217 _connections.reset (new flutter::ConnectionCollection ());
@@ -263,9 +262,9 @@ - (void)setUpApplicationLifecycleNotifications:(NSNotificationCenter*)center {
263262 object: nil ];
264263}
265264
266- - (void )recreatePlatformViewsController {
265+ - (void )recreatePlatformViewController {
267266 _renderingApi = flutter::GetRenderingAPIForProcess (FlutterView.forceSoftwareRendering );
268- _platformViewsController = [[FlutterPlatformViewsController alloc ] init ] ;
267+ _platformViewsController. reset ( new flutter::PlatformViewsController ()) ;
269268}
270269
271270- (flutter::IOSRenderingAPI)platformViewsRenderingAPI {
@@ -453,7 +452,11 @@ - (void)destroyContext {
453452 _shell.reset ();
454453 _profiler.reset ();
455454 _threadHost.reset ();
456- _platformViewsController = nil ;
455+ _platformViewsController.reset ();
456+ }
457+
458+ - (std::shared_ptr<flutter::PlatformViewsController>&)platformViewsController {
459+ return _platformViewsController;
457460}
458461
459462- (NSURL *)observatoryUrl {
@@ -632,7 +635,7 @@ - (void)maybeSetupPlatformViewChannels {
632635 [self .platformViewsChannel
633636 setMethodCallHandler: ^(FlutterMethodCall* call, FlutterResult result) {
634637 if (weakSelf) {
635- [ weakSelf.platformViewsController onMethodCall: call result: result] ;
638+ weakSelf.platformViewsController -> OnMethodCall ( call, result) ;
636639 }
637640 }];
638641
@@ -774,11 +777,11 @@ - (BOOL)createShell:(NSString*)entrypoint
774777 if (!strongSelf) {
775778 return std::unique_ptr<flutter::PlatformViewIOS>();
776779 }
777- [strongSelf recreatePlatformViewsController ];
778- strongSelf. platformViewsController . taskRunner =
779- shell.GetTaskRunners ().GetPlatformTaskRunner ();
780+ [strongSelf recreatePlatformViewController ];
781+ strongSelf-> _platformViewsController -> SetTaskRunner (
782+ shell.GetTaskRunners ().GetPlatformTaskRunner ()) ;
780783 return std::make_unique<flutter::PlatformViewIOS>(
781- shell, strongSelf->_renderingApi , strongSelf. platformViewsController ,
784+ shell, strongSelf->_renderingApi , strongSelf-> _platformViewsController ,
782785 shell.GetTaskRunners (), shell.GetConcurrentWorkerTaskRunner (),
783786 shell.GetIsGpuDisabledSyncSwitch ());
784787 };
@@ -1100,7 +1103,7 @@ - (void)flutterTextInputView:(FlutterTextInputView*)textInputView
11001103 // Have to check in the next run loop, because iOS requests the previous first responder to
11011104 // resign before requesting the next view to become first responder.
11021105 dispatch_async (dispatch_get_main_queue (), ^(void ) {
1103- long platform_view_id = [ self .platformViewsController firstResponderPlatformViewId ] ;
1106+ long platform_view_id = self.platformViewsController -> FindFirstResponderPlatformViewId () ;
11041107 if (platform_view_id == -1 ) {
11051108 return ;
11061109 }
@@ -1397,10 +1400,11 @@ - (FlutterEngine*)spawnWithEntrypoint:(/*nullable*/ NSString*)entrypoint
13971400 // create call is synchronous.
13981401 flutter::Shell::CreateCallback<flutter::PlatformView> on_create_platform_view =
13991402 [result, context](flutter::Shell& shell) {
1400- [result recreatePlatformViewsController ];
1401- result.platformViewsController .taskRunner = shell.GetTaskRunners ().GetPlatformTaskRunner ();
1403+ [result recreatePlatformViewController ];
1404+ result->_platformViewsController ->SetTaskRunner (
1405+ shell.GetTaskRunners ().GetPlatformTaskRunner ());
14021406 return std::make_unique<flutter::PlatformViewIOS>(
1403- shell, context, result. platformViewsController , shell.GetTaskRunners ());
1407+ shell, context, result-> _platformViewsController , shell.GetTaskRunners ());
14041408 };
14051409
14061410 flutter::Shell::CreateCallback<flutter::Rasterizer> on_create_rasterizer =
@@ -1495,9 +1499,8 @@ - (void)registerViewFactory:(NSObject<FlutterPlatformViewFactory>*)factory
14951499 withId : (NSString *)factoryId
14961500 gestureRecognizersBlockingPolicy :
14971501 (FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy {
1498- [_flutterEngine.platformViewsController registerViewFactory: factory
1499- withId: factoryId
1500- gestureRecognizersBlockingPolicy: gestureRecognizersBlockingPolicy];
1502+ [_flutterEngine platformViewsController ]->RegisterViewFactory (factory, factoryId,
1503+ gestureRecognizersBlockingPolicy);
15011504}
15021505
15031506@end
0 commit comments