Avoid null pointer exception after webview is disposed
This commit is contained in:
parent
f6353b8f72
commit
8590e9190d
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue