Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a33e658

Browse files
committed
Reset on hot restart
1 parent 3f70536 commit a33e658

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
1212

1313
@interface FlutterRestorationPlugin : NSObject
14-
1514
- (instancetype)init NS_UNAVAILABLE;
1615
+ (instancetype)new NS_UNAVAILABLE;
1716
- (instancetype)initWithChannel:(FlutterMethodChannel*)channel restorationEnabled:(BOOL)waitForData NS_DESIGNATED_INITIALIZER;
1817

1918
- (NSData*)restorationData;
2019
- (void)restorationData:(NSData *)data;
2120
- (void)restorationComplete;
21+
- (void)reset;
2222
@end
2323
#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERRESTORATIONPLUGIN_H_

shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ - (void)restorationComplete {
8484
}
8585
}
8686

87+
- (void)reset {
88+
if (_restorationData != nil) {
89+
[_restorationData release];
90+
}
91+
_restorationData = nil;
92+
if (_pendingRequest != nil) {
93+
[_pendingRequest release];
94+
}
95+
_pendingRequest = nil;
96+
}
97+
8798
- (NSDictionary*)dataForFramework {
8899
if (!_restorationEnabled) {
89100
return @{ @"enabled": @NO };

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,4 +1449,8 @@ - (void)decodeRestorableStateWithCoder:(NSCoder *)coder {
14491449
[[_engine.get() restorationPlugin] restorationData:restorationData];
14501450
}
14511451

1452+
- (FlutterRestorationPlugin*)restorationPlugin {
1453+
return [_engine.get() restorationPlugin];
1454+
}
1455+
14521456
@end

shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "flutter/fml/memory/weak_ptr.h"
99

1010
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"
11+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h"
1112

1213
namespace flutter {
1314
class FlutterPlatformViewsController;
@@ -27,6 +28,7 @@ extern NSNotificationName const FlutterViewControllerShowHomeIndicator;
2728
@property(nonatomic, readonly) BOOL isPresentingViewController;
2829
- (fml::WeakPtr<FlutterViewController>)getWeakPtr;
2930
- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController;
31+
- (FlutterRestorationPlugin*)restorationPlugin;
3032

3133
@end
3234

shell/platform/darwin/ios/platform_view_ios.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
return;
198198
}
199199
[owner_controller_.get() platformViewsController]->Reset();
200+
[[owner_controller_.get() restorationPlugin] reset];
200201
}
201202

202203
std::unique_ptr<std::vector<std::string>> PlatformViewIOS::ComputePlatformResolvedLocales(

0 commit comments

Comments
 (0)