From 81d83a2421fbd23d2b0dbd7adb51adaf7e4b0788 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 18 Nov 2022 10:59:40 +0100 Subject: [PATCH] Fixed Android NullPointerException on InAppBrowserActivity.dispose --- CHANGELOG.md | 4 ++++ .../in_app_browser/InAppBrowserActivity.java | 6 +++++- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f639eef3b..448da8235 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.7.1+2 + +- Fixed Android `NullPointerException` on `InAppBrowserActivity.dispose` + ## 5.7.1+1 - Fixed User Script remove methods diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java index ca6bd84ef..5eb25e586 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java @@ -46,6 +46,7 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrowserDelegate { static final String LOG_TAG = "InAppBrowserActivity"; + @Nullable public MethodChannel channel; public Integer windowId; public String id; @@ -522,7 +523,10 @@ protected void onActivityResult (int requestCode, } public void dispose() { - channel.setMethodCallHandler(null); + if (channel != null) { + channel.setMethodCallHandler(null); + channel = null; + } activityResultListeners.clear(); if (methodCallDelegate != null) { methodCallDelegate.dispose(); diff --git a/pubspec.yaml b/pubspec.yaml index a6b7ff061..0ec2c245d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 5.7.1+1 +version: 5.7.1+2 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues