runJavascript method

Future<void> runJavascript(
  1. String javaScriptString

Runs the given JavaScript in the context of the current page. If you are looking for the result, use runJavascriptReturningResult instead. The Future completes with an error if a JavaScript error occurred.

When running JavaScript in a WebView, it is best practice to wait for the WebView.onPageFinished callback. This guarantees all the JavaScript embedded in the main frame HTML has been loaded.


Future<void> runJavascript(String javaScriptString) {
  if (_settings.javascriptMode == JavascriptMode.disabled) {
    return Future<void>.error(FlutterError(
        'JavaScript mode must be enabled/unrestricted when calling runJavascript.'));
  return _webViewPlatformController.runJavascript(javaScriptString);