diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java index 9f404803..415fb134 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java @@ -51,6 +51,10 @@ public class JavaScriptBridgeInterface { getChannel().invokeMethod("onCallJsHandler", obj, new MethodChannel.Result() { @Override public void success(Object json) { + if (flutterWebView.webView == null) { + // The webview has already been disposed, ignore. + return; + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { flutterWebView.webView.evaluateJavascript("window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];", null); }