diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java index 376452eb..1cead81b 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java @@ -1525,7 +1525,15 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie public void run() { InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE); - if (containerView != null && imm != null && !imm.isAcceptingText()) { + boolean isAcceptingText = false; + try { + if (imm != null) { + // imm.isAcceptingText() seems to sometimes crash on some devices + isAcceptingText = imm.isAcceptingText(); + } + } catch (Exception ignored) { + } + if (containerView != null && imm != null && !isAcceptingText) { imm.hideSoftInputFromWindow( containerView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index ce252146..139c29e7 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1878,7 +1878,7 @@ class InAppWebViewController { ///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback)) Future canGoBack() async { Map args = {}; - return await _channel?.invokeMethod('canGoBack', args); + return await _channel?.invokeMethod('canGoBack', args) ?? false; } ///Goes forward in the history of the WebView. @@ -1903,7 +1903,7 @@ class InAppWebViewController { ///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward)) Future canGoForward() async { Map args = {}; - return await _channel?.invokeMethod('canGoForward', args); + return await _channel?.invokeMethod('canGoForward', args) ?? false; } ///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.