diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 8df2f3b61dbe9..2e4a265d17f0e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -391,9 +391,9 @@ - (void)viewWillAppear:(BOOL)animated { if (_engineNeedsLaunch) { [_engine.get() launchEngine:nil libraryURI:nil]; + [_engine.get() setViewController:self]; _engineNeedsLaunch = NO; } - [_engine.get() setViewController:self]; // Only recreate surface on subsequent appearances when viewport metrics are known. // First time surface creation is done on viewDidLayoutSubviews. @@ -425,7 +425,6 @@ - (void)viewDidDisappear:(BOOL)animated { TRACE_EVENT0("flutter", "viewDidDisappear"); [self surfaceUpdated:NO]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"]; - [_engine.get() setViewController:nil]; [super viewDidDisappear:animated]; }