@@ -111,22 +111,26 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine
111111 return self;
112112}
113113
114+ - (void )sharedSetupWithProject : (nullable FlutterDartProject*)project {
115+ _viewOpaque = YES ;
116+ _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterViewController>>(self);
117+ _engine.reset ([[FlutterEngine alloc ] initWithName: @" io.flutter"
118+ project: project
119+ allowHeadlessExecution: self .engineAllowHeadlessExecution]);
120+ _flutterView.reset ([[FlutterView alloc ] initWithDelegate: _engine opaque: self .isViewOpaque]);
121+ [_engine.get () createShell: nil libraryURI: nil ];
122+ _engineNeedsLaunch = YES ;
123+ _ongoingTouches = [[NSMutableSet alloc ] init ];
124+ [self loadDefaultSplashScreenView ];
125+ [self performCommonViewControllerInitialization ];
126+ }
127+
114128- (instancetype )initWithProject : (nullable FlutterDartProject*)project
115129 nibName : (nullable NSString *)nibName
116130 bundle : (nullable NSBundle *)nibBundle {
117131 self = [super initWithNibName: nibName bundle: nibBundle];
118132 if (self) {
119- _viewOpaque = YES ;
120- _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterViewController>>(self);
121- _engine.reset ([[FlutterEngine alloc ] initWithName: @" io.flutter"
122- project: project
123- allowHeadlessExecution: NO ]);
124- _flutterView.reset ([[FlutterView alloc ] initWithDelegate: _engine opaque: self .isViewOpaque]);
125- [_engine.get () createShell: nil libraryURI: nil ];
126- _engineNeedsLaunch = YES ;
127- _ongoingTouches = [[NSMutableSet alloc ] init ];
128- [self loadDefaultSplashScreenView ];
129- [self performCommonViewControllerInitialization ];
133+ [self sharedSetupWithProject: project];
130134 }
131135
132136 return self;
@@ -137,7 +141,13 @@ - (instancetype)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBun
137141}
138142
139143- (instancetype )initWithCoder : (NSCoder *)aDecoder {
140- return [self initWithProject: nil nibName: nil bundle: nil ];
144+ self = [super initWithCoder: aDecoder];
145+ return self;
146+ }
147+
148+ - (void )awakeFromNib {
149+ [super awakeFromNib ];
150+ [self sharedSetupWithProject: nil ];
141151}
142152
143153- (instancetype )init {
0 commit comments