diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bb46ec3..f7b4252d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.0-beta.18 + +- Fixed `InAppWebViewSettings` automatic infer if `initialSettings` is `null` + ## 6.0.0-beta.17 - Replaced `Uri.encodeFull` with `Uri.encodeComponent` to load html data correctly on Web platform diff --git a/README.md b/README.md index 5ae8d5a0..249bfd8c 100755 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Migrating from version `5.x.x` is easy! Follow the online [Migration guide](http - [Official blog: inappwebview.dev/blog](https://inappwebview.dev/blog/) - Find open source projects on the [Official Showcase page: inappwebview.dev/showcase](https://inappwebview.dev/showcase/) - Check the [flutter_inappwebview_examples](https://github.com/pichillilorenzo/flutter_inappwebview_examples) repository for project examples -- Check the [example/integration_test/webview_flutter_test.dart](/example/integration_test/webview_flutter_test.dart) file for other code examples +- Check the [example/integration_test/webview_flutter_test.dart](https://github.com/pichillilorenzo/flutter_inappwebview/blob/master/example/integration_test/webview_flutter_test.dart) file for other code examples - [Flutter Browser App](https://github.com/pichillilorenzo/flutter_browser_app): A Full-Featured Mobile Browser App (such as the Google Chrome mobile browser) created using Flutter and the features offered by the flutter_inappwebview plugin ## Showcase - Who use it diff --git a/example/integration_test/in_app_webview/intercept_ajax_request.dart b/example/integration_test/in_app_webview/intercept_ajax_request.dart index d65462ba..d9ffadfd 100644 --- a/example/integration_test/in_app_webview/intercept_ajax_request.dart +++ b/example/integration_test/in_app_webview/intercept_ajax_request.dart @@ -54,9 +54,6 @@ void interceptAjaxRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -143,9 +140,6 @@ void interceptAjaxRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -232,9 +226,6 @@ void interceptAjaxRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -319,9 +310,6 @@ void interceptAjaxRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/intercept_fetch_request.dart b/example/integration_test/in_app_webview/intercept_fetch_request.dart index eb3a3979..fa8ab863 100644 --- a/example/integration_test/in_app_webview/intercept_fetch_request.dart +++ b/example/integration_test/in_app_webview/intercept_fetch_request.dart @@ -63,9 +63,6 @@ void interceptFetchRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -145,9 +142,6 @@ void interceptFetchRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -227,9 +221,6 @@ void interceptFetchRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -305,9 +296,6 @@ void interceptFetchRequest() { """), - initialSettings: InAppWebViewSettings( - clearCache: true, - ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); diff --git a/example/integration_test/in_app_webview/on_download_start_request.dart b/example/integration_test/in_app_webview/on_download_start_request.dart index fcc25ef8..be3f2b41 100644 --- a/example/integration_test/in_app_webview/on_download_start_request.dart +++ b/example/integration_test/in_app_webview/on_download_start_request.dart @@ -45,7 +45,6 @@ void onDownloadStartRequest() { """), - initialSettings: InAppWebViewSettings(clearCache: true), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/on_navigation_response.dart b/example/integration_test/in_app_webview/on_navigation_response.dart index e6d574fe..c21cbbde 100644 --- a/example/integration_test/in_app_webview/on_navigation_response.dart +++ b/example/integration_test/in_app_webview/on_navigation_response.dart @@ -29,7 +29,6 @@ void onNavigationResponse() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: URLRequest(url: TEST_URL_1), - initialSettings: InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -63,7 +62,6 @@ void onNavigationResponse() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: URLRequest(url: TEST_URL_1), - initialSettings: InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/should_intercept_request.dart b/example/integration_test/in_app_webview/should_intercept_request.dart index d6b588ad..7c697d6f 100644 --- a/example/integration_test/in_app_webview/should_intercept_request.dart +++ b/example/integration_test/in_app_webview/should_intercept_request.dart @@ -45,7 +45,6 @@ void shouldInterceptRequest() { """), - initialSettings: InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/should_override_url_loading.dart b/example/integration_test/in_app_webview/should_override_url_loading.dart index 2f8681d1..487c3fad 100644 --- a/example/integration_test/in_app_webview/should_override_url_loading.dart +++ b/example/integration_test/in_app_webview/should_override_url_loading.dart @@ -37,9 +37,6 @@ void shouldOverrideUrlLoading() { onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - ), shouldOverrideUrlLoading: (controller, navigationAction) async { return (navigationAction.request.url!.host .contains(TEST_URL_4.host.replaceAll("www.", ""))) @@ -89,9 +86,6 @@ void shouldOverrideUrlLoading() { onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - ), shouldOverrideUrlLoading: (controller, navigationAction) async { var isFirstLoad = navigationAction.request.url!.scheme == "data"; return (isFirstLoad || @@ -147,9 +141,6 @@ void shouldOverrideUrlLoading() { onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - ), shouldOverrideUrlLoading: (controller, navigationAction) async { return (navigationAction.request.url!.host .contains(TEST_URL_4.host.replaceAll("www.", ""))) @@ -198,9 +189,6 @@ void shouldOverrideUrlLoading() { onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - ), shouldOverrideUrlLoading: (controller, navigationAction) async { var action = NavigationActionPolicy.CANCEL; action = await Future.delayed( diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index 231342d0..92c1db75 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -214,15 +214,14 @@ class HeadlessInAppWebView implements WebView, Disposable { } _started = true; - final initialSettings = this.initialSettings; - if (initialSettings != null) { - _inferInitialSettings(initialSettings); - } + final initialSettings = this.initialSettings ?? InAppWebViewSettings(); + _inferInitialSettings(initialSettings); - Map settingsMap = initialSettings?.toMap() ?? - // ignore: deprecated_member_use_from_same_package - this.initialOptions?.toMap() ?? - {}; + Map settingsMap = + (this.initialSettings != null ? initialSettings.toMap() : null) ?? + // ignore: deprecated_member_use_from_same_package + this.initialOptions?.toMap() ?? + initialSettings.toMap(); Map pullToRefreshSettings = this.pullToRefreshController?.settings.toMap() ?? diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index 53afcb5d..83cb6edb 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -624,15 +624,14 @@ class _InAppWebViewState extends State { @override Widget build(BuildContext context) { - final initialSettings = widget.initialSettings; - if (initialSettings != null) { - _inferInitialSettings(initialSettings); - } + final initialSettings = widget.initialSettings ?? InAppWebViewSettings(); + _inferInitialSettings(initialSettings); - Map settingsMap = initialSettings?.toMap() ?? - // ignore: deprecated_member_use_from_same_package - widget.initialOptions?.toMap() ?? - {}; + Map settingsMap = + (widget.initialSettings != null ? initialSettings.toMap() : null) ?? + // ignore: deprecated_member_use_from_same_package + widget.initialOptions?.toMap() ?? + initialSettings.toMap(); Map pullToRefreshSettings = widget.pullToRefreshController?.settings.toMap() ?? @@ -645,7 +644,7 @@ class _InAppWebViewState extends State { viewType: 'com.pichillilorenzo/flutter_inappwebview', onPlatformViewCreated: (int viewId) { var webViewHtmlElement = WebPlatformManager.webViews[viewId]!; - webViewHtmlElement.initialSettings = widget.initialSettings; + webViewHtmlElement.initialSettings = initialSettings; webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest; webViewHtmlElement.initialFile = widget.initialFile; webViewHtmlElement.initialData = widget.initialData; @@ -662,7 +661,7 @@ class _InAppWebViewState extends State { ); } else if (defaultTargetPlatform == TargetPlatform.android) { var useHybridComposition = (widget.initialSettings != null - ? widget.initialSettings?.useHybridComposition + ? initialSettings.useHybridComposition : // ignore: deprecated_member_use_from_same_package widget.initialOptions?.android.useHybridComposition) ?? diff --git a/pubspec.yaml b/pubspec.yaml index b76801f5..4d71a351 100755 --- 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: 6.0.0-beta.17 +version: 6.0.0-beta.18 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues