@@ -111,22 +111,26 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine
111
111
return self;
112
112
}
113
113
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
+
114
128
- (instancetype )initWithProject : (nullable FlutterDartProject*)project
115
129
nibName : (nullable NSString *)nibName
116
130
bundle : (nullable NSBundle *)nibBundle {
117
131
self = [super initWithNibName: nibName bundle: nibBundle];
118
132
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];
130
134
}
131
135
132
136
return self;
@@ -137,7 +141,15 @@ - (instancetype)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBun
137
141
}
138
142
139
143
- (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
+ if (!_engine.get ()) {
151
+ [self sharedSetupWithProject: nil ];
152
+ }
141
153
}
142
154
143
155
- (instancetype )init {
0 commit comments