@@ -71,8 +71,10 @@ @implementation FlutterEngine {
71
71
// Channels
72
72
fml::scoped_nsobject<FlutterPlatformPlugin> _platformPlugin;
73
73
fml::scoped_nsobject<FlutterTextInputPlugin> _textInputPlugin;
74
+ fml::scoped_nsobject<FlutterRestorationPlugin> _restorationPlugin;
74
75
fml::scoped_nsobject<FlutterMethodChannel> _localizationChannel;
75
76
fml::scoped_nsobject<FlutterMethodChannel> _navigationChannel;
77
+ fml::scoped_nsobject<FlutterMethodChannel> _restorationChannel;
76
78
fml::scoped_nsobject<FlutterMethodChannel> _platformChannel;
77
79
fml::scoped_nsobject<FlutterMethodChannel> _platformViewsChannel;
78
80
fml::scoped_nsobject<FlutterMethodChannel> _textInputChannel;
@@ -84,6 +86,7 @@ @implementation FlutterEngine {
84
86
int64_t _nextTextureId;
85
87
86
88
BOOL _allowHeadlessExecution;
89
+ BOOL _restorationEnabled;
87
90
FlutterBinaryMessengerRelay* _binaryMessenger;
88
91
std::unique_ptr<flutter::ConnectionCollection> _connections;
89
92
}
@@ -103,10 +106,21 @@ - (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*
103
106
- (instancetype )initWithName : (NSString *)labelPrefix
104
107
project : (FlutterDartProject*)project
105
108
allowHeadlessExecution : (BOOL )allowHeadlessExecution {
109
+ return [self initWithName: labelPrefix
110
+ project: project
111
+ allowHeadlessExecution: allowHeadlessExecution
112
+ restorationEnabled: NO ];
113
+ }
114
+
115
+ - (instancetype )initWithName : (NSString *)labelPrefix
116
+ project : (FlutterDartProject*)project
117
+ allowHeadlessExecution : (BOOL )allowHeadlessExecution
118
+ restorationEnabled : (BOOL )restorationEnabled {
106
119
self = [super init ];
107
120
NSAssert (self, @" Super init cannot be nil" );
108
121
NSAssert (labelPrefix, @" labelPrefix is required" );
109
122
123
+ _restorationEnabled = restorationEnabled;
110
124
_allowHeadlessExecution = allowHeadlessExecution;
111
125
_labelPrefix = [labelPrefix copy ];
112
126
@@ -331,12 +345,18 @@ - (FlutterPlatformPlugin*)platformPlugin {
331
345
- (FlutterTextInputPlugin*)textInputPlugin {
332
346
return _textInputPlugin.get ();
333
347
}
348
+ - (FlutterRestorationPlugin*)restorationPlugin {
349
+ return _restorationPlugin.get ();
350
+ }
334
351
- (FlutterMethodChannel*)localizationChannel {
335
352
return _localizationChannel.get ();
336
353
}
337
354
- (FlutterMethodChannel*)navigationChannel {
338
355
return _navigationChannel.get ();
339
356
}
357
+ - (FlutterMethodChannel*)restorationChannel {
358
+ return _restorationChannel.get ();
359
+ }
340
360
- (FlutterMethodChannel*)platformChannel {
341
361
return _platformChannel.get ();
342
362
}
@@ -363,6 +383,7 @@ - (NSURL*)observatoryUrl {
363
383
- (void )resetChannels {
364
384
_localizationChannel.reset ();
365
385
_navigationChannel.reset ();
386
+ _restorationChannel.reset ();
366
387
_platformChannel.reset ();
367
388
_platformViewsChannel.reset ();
368
389
_textInputChannel.reset ();
@@ -413,6 +434,11 @@ - (void)setupChannels {
413
434
_initialRoute = nil ;
414
435
}
415
436
437
+ _restorationChannel.reset ([[FlutterMethodChannel alloc ]
438
+ initWithName: @" flutter/restoration"
439
+ binaryMessenger: self .binaryMessenger
440
+ codec: [FlutterStandardMethodCodec sharedInstance ]]);
441
+
416
442
_platformChannel.reset ([[FlutterMethodChannel alloc ]
417
443
initWithName: @" flutter/platform"
418
444
binaryMessenger: self .binaryMessenger
@@ -452,6 +478,10 @@ - (void)setupChannels {
452
478
_textInputPlugin.get ().textInputDelegate = self;
453
479
454
480
_platformPlugin.reset ([[FlutterPlatformPlugin alloc ] initWithEngine: [self getWeakPtr ]]);
481
+
482
+ _restorationPlugin.reset ([[FlutterRestorationPlugin alloc ]
483
+ initWithChannel: _restorationChannel.get ()
484
+ restorationEnabled: _restorationEnabled]);
455
485
}
456
486
457
487
- (void )maybeSetupPlatformViewChannels {
0 commit comments