Skip to content

Commit

Permalink
Avoid null pointer exception after webview is disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonmeemo committed Jun 11, 2019
1 parent f6353b8 commit 8590e91
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8590e91

Please sign in to comment.