ponnamkarthik/FlutterWebView

MissingPluginException on iOS

amsmu opened this issue · 3 comments

amsmu commented

"No implementation found for method loadData on channel ponnamkarthik/flutterwebview_0"

Edit the source to fix this.

FlutterWebView.m

#import "FlutterWebView.h"

...

- (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  if ([[call method] isEqualToString:@"loadUrl"]) {
    [self onLoadUrl:call result:result];
  } else if ([[call method] isEqualToString:@"loadData"]) {
      [self onLoadData:call result:result];
  } else {
    result(FlutterMethodNotImplemented);
  }
}

...


- (void)onLoadData:(FlutterMethodCall*)call result:(FlutterResult)result {
    NSString* data = [call arguments];
    if (![self loadData:data]) {
        result([FlutterError errorWithCode:@"loadData_failed"
                                   message:@"Failed parsing the data"
                                   details:[NSString stringWithFormat:@"data was: '%@'", data]]);
    } else {
        result(nil);
    }
}

- (bool)loadData:(NSString*)data {
   
    [_webView loadHTMLString:data baseURL:nil];
    return true;
}

@end

created PR #8

updated v1.0.1