From 440ff8180331b516f12fc0229ecec03529bf27e2 Mon Sep 17 00:00:00 2001 From: RodXander Date: Wed, 22 Dec 2021 16:51:38 -0600 Subject: [PATCH] Fixed the unexpected behavior of InAppWebView and HeadlessInAppWebView when initialUrlRequest was set as null. --- lib/src/in_app_webview/headless_in_app_webview.dart | 4 +--- lib/src/in_app_webview/in_app_webview.dart | 12 +++--------- 2 files changed, 4 insertions(+), 12 deletions(-) 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 f19b5152..3185aa92 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -139,9 +139,7 @@ class HeadlessInAppWebView implements WebView { args.putIfAbsent( 'params', () => { - 'initialUrlRequest': (this.initialUrlRequest ?? - URLRequest(url: Uri.parse("about:blank"))) - .toMap(), + 'initialUrlRequest': this.initialUrlRequest?.toMap(), 'initialFile': this.initialFile, 'initialData': this.initialData?.toMap(), 'initialOptions': this.initialOptions?.toMap() ?? {}, diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index 7ef7ee2f..f16e5eb5 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -395,9 +395,7 @@ class _InAppWebViewState extends State { viewType: 'com.pichillilorenzo/flutter_inappwebview', layoutDirection: TextDirection.rtl, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? - URLRequest(url: Uri.parse("about:blank"))) - .toMap(), + 'initialUrlRequest': widget.initialUrlRequest?.toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {}, @@ -425,9 +423,7 @@ class _InAppWebViewState extends State { gestureRecognizers: widget.gestureRecognizers, layoutDirection: TextDirection.rtl, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? - URLRequest(url: Uri.parse("about:blank"))) - .toMap(), + 'initialUrlRequest': widget.initialUrlRequest?.toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {}, @@ -448,9 +444,7 @@ class _InAppWebViewState extends State { onPlatformViewCreated: _onPlatformViewCreated, gestureRecognizers: widget.gestureRecognizers, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? - URLRequest(url: Uri.parse("about:blank"))) - .toMap(), + 'initialUrlRequest': widget.initialUrlRequest?.toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {},