handleMethodCall method
Handles method calls over the MethodChannel of this plugin.
Implementation
Future<dynamic> handleMethodCall(MethodCall call) async {
switch (call.method) {
case "getIFrameId":
return getIFrameId();
case "loadUrl":
URLRequest urlRequest = URLRequest.fromMap(
call.arguments["urlRequest"].cast<String, dynamic>())!;
await loadUrl(urlRequest: urlRequest);
break;
case "loadData":
String data = call.arguments["data"];
String mimeType = call.arguments["mimeType"];
await loadData(data: data, mimeType: mimeType);
break;
case "loadFile":
String assetFilePath = call.arguments["assetFilePath"];
await loadFile(assetFilePath: assetFilePath);
break;
case "reload":
await reload();
break;
case "goBack":
await goBack();
break;
case "goForward":
await goForward();
break;
case "goBackOrForward":
int steps = call.arguments["steps"];
await goBackOrForward(steps: steps);
break;
case "isLoading":
return isLoading;
case "evaluateJavascript":
String source = call.arguments["source"];
return await evaluateJavascript(source: source);
case "stopLoading":
await stopLoading();
break;
case "getSettings":
return await getSettings();
case "setSettings":
InAppWebViewSettings newSettings = InAppWebViewSettings.fromMap(
call.arguments["settings"].cast<String, dynamic>()) ??
InAppWebViewSettings();
await setSettings(newSettings);
break;
case "getUrl":
return await getUrl();
case "getTitle":
return await getTitle();
case "postUrl":
String url = call.arguments["url"];
Uint8List postData = call.arguments["postData"];
return await postUrl(url: url, postData: postData);
case "injectJavascriptFileFromUrl":
String urlFile = call.arguments["urlFile"];
Map<String, dynamic> scriptHtmlTagAttributes =
call.arguments["scriptHtmlTagAttributes"].cast<String, dynamic>();
await injectJavascriptFileFromUrl(
urlFile: urlFile, scriptHtmlTagAttributes: scriptHtmlTagAttributes);
break;
case "injectCSSCode":
String source = call.arguments["source"];
await injectCSSCode(source: source);
break;
case "injectCSSFileFromUrl":
String urlFile = call.arguments["urlFile"];
Map<String, dynamic> cssLinkHtmlTagAttributes =
call.arguments["cssLinkHtmlTagAttributes"].cast<String, dynamic>();
await injectCSSFileFromUrl(
urlFile: urlFile,
cssLinkHtmlTagAttributes: cssLinkHtmlTagAttributes);
break;
case "scrollTo":
int x = call.arguments["x"];
int y = call.arguments["y"];
bool animated = call.arguments["animated"];
await scrollTo(x: x, y: y, animated: animated);
break;
case "scrollBy":
int x = call.arguments["x"];
int y = call.arguments["y"];
bool animated = call.arguments["animated"];
await scrollBy(x: x, y: y, animated: animated);
break;
case "printCurrentPage":
await printCurrentPage();
break;
case "getContentHeight":
return await getContentHeight();
case "getContentWidth":
return await getContentWidth();
case "getOriginalUrl":
return await getOriginalUrl();
case "getSelectedText":
return await getSelectedText();
case "getScrollX":
return await getScrollX();
case "getScrollY":
return await getScrollY();
case "isSecureContext":
return await isSecureContext();
case "canScrollVertically":
return await canScrollVertically();
case "canScrollHorizontally":
return await canScrollHorizontally();
case "dispose":
dispose();
break;
default:
throw PlatformException(
code: 'Unimplemented',
details:
'flutter_adeeinappwebview for web doesn\'t implement \'${call.method}\'',
);
}
return null;
}