From 8590e9190dfb9eb1609e7a6f93de2909f6006331 Mon Sep 17 00:00:00 2001 From: Robson Araujo Date: Tue, 11 Jun 2019 14:22:46 -0700 Subject: [PATCH] Avoid null pointer exception after webview is disposed --- .../flutter_inappbrowser/JavaScriptBridgeInterface.java | 4 ++++ 1 file changed, 4 insertions(+) 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 9f404803c..415fb134e 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 void run() { 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); }