Fixed InAppWebViewSettings automatic infer if initialSettings is null

This commit is contained in:
Lorenzo Pichilli 2022-11-28 15:12:02 +01:00
parent ae4471d4c0
commit 2d32eff3f0
11 changed files with 22 additions and 60 deletions

View File

@ -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

View File

@ -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

View File

@ -54,9 +54,6 @@ void interceptAjaxRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
@ -143,9 +140,6 @@ void interceptAjaxRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
@ -232,9 +226,6 @@ void interceptAjaxRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
@ -319,9 +310,6 @@ void interceptAjaxRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},

View File

@ -63,9 +63,6 @@ void interceptFetchRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
@ -145,9 +142,6 @@ void interceptFetchRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
@ -227,9 +221,6 @@ void interceptFetchRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
@ -305,9 +296,6 @@ void interceptFetchRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);

View File

@ -45,7 +45,6 @@ void onDownloadStartRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(clearCache: true),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},

View File

@ -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);
},

View File

@ -45,7 +45,6 @@ void shouldInterceptRequest() {
</body>
</html>
"""),
initialSettings: InAppWebViewSettings(),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},

View File

@ -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<NavigationActionPolicy>.delayed(

View File

@ -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<String, dynamic> settingsMap = initialSettings?.toMap() ??
// ignore: deprecated_member_use_from_same_package
this.initialOptions?.toMap() ??
{};
Map<String, dynamic> settingsMap =
(this.initialSettings != null ? initialSettings.toMap() : null) ??
// ignore: deprecated_member_use_from_same_package
this.initialOptions?.toMap() ??
initialSettings.toMap();
Map<String, dynamic> pullToRefreshSettings =
this.pullToRefreshController?.settings.toMap() ??

View File

@ -624,15 +624,14 @@ class _InAppWebViewState extends State<InAppWebView> {
@override
Widget build(BuildContext context) {
final initialSettings = widget.initialSettings;
if (initialSettings != null) {
_inferInitialSettings(initialSettings);
}
final initialSettings = widget.initialSettings ?? InAppWebViewSettings();
_inferInitialSettings(initialSettings);
Map<String, dynamic> settingsMap = initialSettings?.toMap() ??
// ignore: deprecated_member_use_from_same_package
widget.initialOptions?.toMap() ??
{};
Map<String, dynamic> settingsMap =
(widget.initialSettings != null ? initialSettings.toMap() : null) ??
// ignore: deprecated_member_use_from_same_package
widget.initialOptions?.toMap() ??
initialSettings.toMap();
Map<String, dynamic> pullToRefreshSettings =
widget.pullToRefreshController?.settings.toMap() ??
@ -645,7 +644,7 @@ class _InAppWebViewState extends State<InAppWebView> {
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<InAppWebView> {
);
} 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) ??

View File

@ -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