Here's the code that auto-registers an engine at the last minute:
|
if ([scene.delegate conformsToProtocol:@protocol(UIWindowSceneDelegate)]) { |
|
NSObject<UIWindowSceneDelegate>* sceneDelegate = |
|
(NSObject<UIWindowSceneDelegate>*)scene.delegate; |
|
if ([sceneDelegate.window.rootViewController isKindOfClass:[FlutterViewController class]]) { |
|
FlutterViewController* rootViewController = |
|
(FlutterViewController*)sceneDelegate.window.rootViewController; |
|
[self addFlutterManagedEngine:rootViewController.engine]; |
|
} |
|
} |
My understanding is that, this code is in-place because the engine hasn't been added to the listeners list when sceneWillConnect is called, So it performs a workaround at last minute, to see if the rootVC is a FlutterVC, and if so, registers the engine.
This is missing corner cases when FlutterVC isn't the rootVC.
Note that this is for multi-scene scenario.
Here's the code that auto-registers an engine at the last minute:
flutter/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterSceneLifeCycle.mm
Lines 195 to 203 in 61fca76
My understanding is that, this code is in-place because the engine hasn't been added to the listeners list when
sceneWillConnectis called, So it performs a workaround at last minute, to see if therootVCis a FlutterVC, and if so, registers the engine.This is missing corner cases when FlutterVC isn't the rootVC.
Note that this is for multi-scene scenario.