Avoid null pointer exception after webview is disposed

This commit is contained in:
Robson Araujo 2019-06-11 14:22:46 -07:00
parent f6353b8f72
commit 8590e9190d
1 changed files with 4 additions and 0 deletions

View File

@ -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);
}