Merge pull request #116 from robsonfingo/master
Avoid null pointer exception after webview is disposed
This commit is contained in:
commit
07f63a5f23
|
@ -51,6 +51,10 @@ public class JavaScriptBridgeInterface {
|
||||||
getChannel().invokeMethod("onCallJsHandler", obj, new MethodChannel.Result() {
|
getChannel().invokeMethod("onCallJsHandler", obj, new MethodChannel.Result() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Object json) {
|
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
flutterWebView.webView.evaluateJavascript("window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];", null);
|
flutterWebView.webView.evaluateJavascript("window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];", null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue