File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,14 @@ - (UIView*)view {
60
60
- (void )onMethodCall : (FlutterMethodCall*)call result : (FlutterResult)result {
61
61
if ([[call method ] isEqualToString: @" loadUrl" ]) {
62
62
[self onLoadUrl: call result: result];
63
+ } else if ([[call method ] isEqualToString: @" loadData" ]) {
64
+ [self onLoadData: call result: result];
63
65
} else {
64
66
result (FlutterMethodNotImplemented);
65
67
}
66
68
}
67
69
70
+
68
71
- (void )onLoadUrl : (FlutterMethodCall*)call result : (FlutterResult)result {
69
72
NSString * url = [call arguments ];
70
73
if (![self loadUrl: url]) {
@@ -86,4 +89,22 @@ - (bool)loadUrl:(NSString*)url {
86
89
return true ;
87
90
}
88
91
89
- @end
92
+
93
+ - (void )onLoadData : (FlutterMethodCall*)call result : (FlutterResult)result {
94
+ NSString * data = [call arguments ];
95
+ if (![self loadData: data]) {
96
+ result ([FlutterError errorWithCode: @" loadData_failed"
97
+ message: @" Failed parsing the data"
98
+ details: [NSString stringWithFormat: @" data was: '%@ '" , data]]);
99
+ } else {
100
+ result (nil );
101
+ }
102
+ }
103
+
104
+ - (bool )loadData : (NSString *)data {
105
+
106
+ [_webView loadHTMLString: data baseURL: nil ];
107
+ return true ;
108
+ }
109
+
110
+ @end
You can’t perform that action at this time.
0 commit comments