Fixed InAppWebViewSettings automatic infer if initialSettings is null
This commit is contained in:
parent
ae4471d4c0
commit
2d32eff3f0
@ -1,3 +1,7 @@
|
|||||||
|
## 6.0.0-beta.18
|
||||||
|
|
||||||
|
- Fixed `InAppWebViewSettings` automatic infer if `initialSettings` is `null`
|
||||||
|
|
||||||
## 6.0.0-beta.17
|
## 6.0.0-beta.17
|
||||||
|
|
||||||
- Replaced `Uri.encodeFull` with `Uri.encodeComponent` to load html data correctly on Web platform
|
- Replaced `Uri.encodeFull` with `Uri.encodeComponent` to load html data correctly on Web platform
|
||||||
|
@ -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/)
|
- [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/)
|
- 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 [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
|
- [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
|
## Showcase - Who use it
|
||||||
|
@ -54,9 +54,6 @@ void interceptAjaxRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
@ -143,9 +140,6 @@ void interceptAjaxRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
@ -232,9 +226,6 @@ void interceptAjaxRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
@ -319,9 +310,6 @@ void interceptAjaxRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -63,9 +63,6 @@ void interceptFetchRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
||||||
@ -145,9 +142,6 @@ void interceptFetchRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
||||||
@ -227,9 +221,6 @@ void interceptFetchRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
||||||
@ -305,9 +296,6 @@ void interceptFetchRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
clearCache: true,
|
|
||||||
),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ void onDownloadStartRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(clearCache: true),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,6 @@ void onNavigationResponse() {
|
|||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
initialUrlRequest: URLRequest(url: TEST_URL_1),
|
initialUrlRequest: URLRequest(url: TEST_URL_1),
|
||||||
initialSettings: InAppWebViewSettings(),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
@ -63,7 +62,6 @@ void onNavigationResponse() {
|
|||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
initialUrlRequest: URLRequest(url: TEST_URL_1),
|
initialUrlRequest: URLRequest(url: TEST_URL_1),
|
||||||
initialSettings: InAppWebViewSettings(),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,6 @@ void shouldInterceptRequest() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""),
|
"""),
|
||||||
initialSettings: InAppWebViewSettings(),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -37,9 +37,6 @@ void shouldOverrideUrlLoading() {
|
|||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
javaScriptEnabled: true,
|
|
||||||
),
|
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
return (navigationAction.request.url!.host
|
return (navigationAction.request.url!.host
|
||||||
.contains(TEST_URL_4.host.replaceAll("www.", "")))
|
.contains(TEST_URL_4.host.replaceAll("www.", "")))
|
||||||
@ -89,9 +86,6 @@ void shouldOverrideUrlLoading() {
|
|||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
javaScriptEnabled: true,
|
|
||||||
),
|
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
var isFirstLoad = navigationAction.request.url!.scheme == "data";
|
var isFirstLoad = navigationAction.request.url!.scheme == "data";
|
||||||
return (isFirstLoad ||
|
return (isFirstLoad ||
|
||||||
@ -147,9 +141,6 @@ void shouldOverrideUrlLoading() {
|
|||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
javaScriptEnabled: true,
|
|
||||||
),
|
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
return (navigationAction.request.url!.host
|
return (navigationAction.request.url!.host
|
||||||
.contains(TEST_URL_4.host.replaceAll("www.", "")))
|
.contains(TEST_URL_4.host.replaceAll("www.", "")))
|
||||||
@ -198,9 +189,6 @@ void shouldOverrideUrlLoading() {
|
|||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
initialSettings: InAppWebViewSettings(
|
|
||||||
javaScriptEnabled: true,
|
|
||||||
),
|
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
var action = NavigationActionPolicy.CANCEL;
|
var action = NavigationActionPolicy.CANCEL;
|
||||||
action = await Future<NavigationActionPolicy>.delayed(
|
action = await Future<NavigationActionPolicy>.delayed(
|
||||||
|
@ -214,15 +214,14 @@ class HeadlessInAppWebView implements WebView, Disposable {
|
|||||||
}
|
}
|
||||||
_started = true;
|
_started = true;
|
||||||
|
|
||||||
final initialSettings = this.initialSettings;
|
final initialSettings = this.initialSettings ?? InAppWebViewSettings();
|
||||||
if (initialSettings != null) {
|
_inferInitialSettings(initialSettings);
|
||||||
_inferInitialSettings(initialSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> settingsMap = initialSettings?.toMap() ??
|
Map<String, dynamic> settingsMap =
|
||||||
// ignore: deprecated_member_use_from_same_package
|
(this.initialSettings != null ? initialSettings.toMap() : null) ??
|
||||||
this.initialOptions?.toMap() ??
|
// ignore: deprecated_member_use_from_same_package
|
||||||
{};
|
this.initialOptions?.toMap() ??
|
||||||
|
initialSettings.toMap();
|
||||||
|
|
||||||
Map<String, dynamic> pullToRefreshSettings =
|
Map<String, dynamic> pullToRefreshSettings =
|
||||||
this.pullToRefreshController?.settings.toMap() ??
|
this.pullToRefreshController?.settings.toMap() ??
|
||||||
|
@ -624,15 +624,14 @@ class _InAppWebViewState extends State<InAppWebView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final initialSettings = widget.initialSettings;
|
final initialSettings = widget.initialSettings ?? InAppWebViewSettings();
|
||||||
if (initialSettings != null) {
|
_inferInitialSettings(initialSettings);
|
||||||
_inferInitialSettings(initialSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> settingsMap = initialSettings?.toMap() ??
|
Map<String, dynamic> settingsMap =
|
||||||
// ignore: deprecated_member_use_from_same_package
|
(widget.initialSettings != null ? initialSettings.toMap() : null) ??
|
||||||
widget.initialOptions?.toMap() ??
|
// ignore: deprecated_member_use_from_same_package
|
||||||
{};
|
widget.initialOptions?.toMap() ??
|
||||||
|
initialSettings.toMap();
|
||||||
|
|
||||||
Map<String, dynamic> pullToRefreshSettings =
|
Map<String, dynamic> pullToRefreshSettings =
|
||||||
widget.pullToRefreshController?.settings.toMap() ??
|
widget.pullToRefreshController?.settings.toMap() ??
|
||||||
@ -645,7 +644,7 @@ class _InAppWebViewState extends State<InAppWebView> {
|
|||||||
viewType: 'com.pichillilorenzo/flutter_inappwebview',
|
viewType: 'com.pichillilorenzo/flutter_inappwebview',
|
||||||
onPlatformViewCreated: (int viewId) {
|
onPlatformViewCreated: (int viewId) {
|
||||||
var webViewHtmlElement = WebPlatformManager.webViews[viewId]!;
|
var webViewHtmlElement = WebPlatformManager.webViews[viewId]!;
|
||||||
webViewHtmlElement.initialSettings = widget.initialSettings;
|
webViewHtmlElement.initialSettings = initialSettings;
|
||||||
webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest;
|
webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest;
|
||||||
webViewHtmlElement.initialFile = widget.initialFile;
|
webViewHtmlElement.initialFile = widget.initialFile;
|
||||||
webViewHtmlElement.initialData = widget.initialData;
|
webViewHtmlElement.initialData = widget.initialData;
|
||||||
@ -662,7 +661,7 @@ class _InAppWebViewState extends State<InAppWebView> {
|
|||||||
);
|
);
|
||||||
} else if (defaultTargetPlatform == TargetPlatform.android) {
|
} else if (defaultTargetPlatform == TargetPlatform.android) {
|
||||||
var useHybridComposition = (widget.initialSettings != null
|
var useHybridComposition = (widget.initialSettings != null
|
||||||
? widget.initialSettings?.useHybridComposition
|
? initialSettings.useHybridComposition
|
||||||
:
|
:
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
widget.initialOptions?.android.useHybridComposition) ??
|
widget.initialOptions?.android.useHybridComposition) ??
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: flutter_inappwebview
|
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.
|
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/
|
homepage: https://inappwebview.dev/
|
||||||
repository: https://github.com/pichillilorenzo/flutter_inappwebview
|
repository: https://github.com/pichillilorenzo/flutter_inappwebview
|
||||||
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
||||||
|
Loading…
x
Reference in New Issue
Block a user