Skip to content

Commit

Permalink
Merge pull request #116 from robsonfingo/master
Browse files Browse the repository at this point in the history
Avoid null pointer exception after webview is disposed
  • Loading branch information
pichillilorenzo committed Oct 24, 2019
2 parents d7edfc5 + 8590e91 commit 07f63a5
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 07f63a5

Please sign in to comment.