7 #import <Foundation/Foundation.h>
8 #import <UIKit/UIKit.h>
10 #include "flutter/fml/logging.h"
24 restorationEnabled:(BOOL)restorationEnabled {
25 FML_DCHECK(channel) <<
"channel must be set";
29 [
self handleMethodCall:call result:result];
32 _waitForData = restorationEnabled;
38 if ([[call method] isEqualToString:
@"put"]) {
39 NSAssert(
self.pendingRequest == nil,
@"Cannot put data while a get request is pending.");
41 self.restorationData = [data
data];
43 }
else if ([[call method] isEqualToString:
@"get"]) {
45 result([
self dataForFramework]);
48 NSAssert(
self.pendingRequest == nil,
@"There can only be one pending request.");
49 self.pendingRequest = result;
55 - (void)setRestorationData:(NSData*)data {
56 if (data != _restorationData) {
57 _restorationData = [data copy];
60 if (
self.pendingRequest != nil) {
61 self.pendingRequest([
self dataForFramework]);
62 self.pendingRequest = nil;
66 - (void)markRestorationComplete {
68 if (
self.pendingRequest != nil) {
70 self.pendingRequest([
self dataForFramework]);
71 self.pendingRequest = nil;
76 self.pendingRequest = nil;
77 self.restorationData = nil;
80 - (NSDictionary*)dataForFramework {
82 return @{
@"enabled" : @NO};
84 if (
self.restorationData == nil) {
85 return @{
@"enabled" : @YES};