From c2ce274754be06c879f3fe733e4429ec70be4e94 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli <pichillilorenzo@gmail.com> Date: Wed, 23 Nov 2022 17:04:09 +0100 Subject: [PATCH] Removed Android Hybrid Composition constraint to use the pull-to-refresh feature --- CHANGELOG.md | 4 ++++ .../in_app_webview/FlutterWebView.java | 18 ++++++++---------- lib/src/in_app_webview/in_app_webview.dart | 5 ----- pubspec.yaml | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 448da823..f9a054dd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.7.2 + +- Removed Android Hybrid Composition constraint to use the pull-to-refresh feature + ## 5.7.1+2 - Fixed Android `NullPointerException` on `InAppBrowserActivity.dispose` diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/FlutterWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/FlutterWebView.java index 2afadea9..4d387379 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/FlutterWebView.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/FlutterWebView.java @@ -70,16 +70,14 @@ public class FlutterWebView implements PlatformWebView { webView = new InAppWebView(context, plugin, channel, id, windowId, options, contextMenu, options.useHybridComposition ? null : plugin.flutterView, userScripts); displayListenerProxy.onPostWebViewInitialization(displayManager); - if (options.useHybridComposition) { - // set MATCH_PARENT layout params to the WebView, otherwise it won't take all the available space! - webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - MethodChannel pullToRefreshLayoutChannel = new MethodChannel(plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id); - PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions(); - pullToRefreshOptions.parse(pullToRefreshInitialOptions); - pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshOptions); - pullToRefreshLayout.addView(webView); - pullToRefreshLayout.prepare(); - } + // set MATCH_PARENT layout params to the WebView, otherwise it won't take all the available space! + webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + MethodChannel pullToRefreshLayoutChannel = new MethodChannel(plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id); + PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions(); + pullToRefreshOptions.parse(pullToRefreshInitialOptions); + pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshOptions); + pullToRefreshLayout.addView(webView); + pullToRefreshLayout.prepare(); methodCallDelegate = new InAppWebViewMethodHandler(webView); channel.setMethodCallHandler(methodCallDelegate); diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index 323b4c53..826b3675 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -381,11 +381,6 @@ class _InAppWebViewState extends State<InAppWebView> { var useHybridComposition = widget.initialOptions?.android.useHybridComposition ?? false; - if (!useHybridComposition && widget.pullToRefreshController != null) { - throw new Exception( - "To use the pull-to-refresh feature, useHybridComposition Android-specific option MUST be true!"); - } - return PlatformViewLink( viewType: 'com.pichillilorenzo/flutter_inappwebview', surfaceFactory: ( diff --git a/pubspec.yaml b/pubspec.yaml index 0ec2c245..6137ff9d 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+2 +version: 5.7.2 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues -- GitLab