Created WebUri class to replace Uri dart core type, fix #1402, fix #1328, fix #1350

This commit is contained in:
Lorenzo Pichilli 2022-10-27 11:02:49 +02:00
parent 52fb4b3263
commit fa5449a50d
92 changed files with 579 additions and 307 deletions

View File

@ -1,3 +1,14 @@
## 6.0.0-beta.10
- Created `WebUri` class to replace `Uri` dart core type. Related to:
- "Uri.tryParse will make the host to be lowercase" [#1402](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1402)
- "An error occurs when using a specific intent" [#1328](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1328)
- "Android shouldOverrideUrlLoading not working" [#1350](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1350)
### BREAKING CHANGES
- Replaced the usage of `Uri` type with the new `WebUri` type
## 6.0.0-beta.9 ## 6.0.0-beta.9
- Added `headers`, `otherLikelyURLs`, `referrer` arguments on `ChromeSafariBrowser.open` method for Android - Added `headers`, `otherLikelyURLs`, `referrer` arguments on `ChromeSafariBrowser.open` method for Android

View File

@ -1,6 +1,5 @@
package com.pichillilorenzo.flutter_inappwebview.types; package com.pichillilorenzo.flutter_inappwebview.types;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.webkit.WebResourceRequest; import android.webkit.WebResourceRequest;
@ -14,14 +13,14 @@ import java.util.Map;
public class WebResourceRequestExt { public class WebResourceRequestExt {
@NonNull @NonNull
private Uri url; private String url;
private Map<String, String> headers; private Map<String, String> headers;
private boolean isRedirect; private boolean isRedirect;
private boolean hasGesture; private boolean hasGesture;
private boolean isForMainFrame; private boolean isForMainFrame;
private String method; private String method;
public WebResourceRequestExt(@NonNull Uri url, Map<String, String> headers, boolean isRedirect, boolean hasGesture, boolean isForMainFrame, String method) { public WebResourceRequestExt(@NonNull String url, Map<String, String> headers, boolean isRedirect, boolean hasGesture, boolean isForMainFrame, String method) {
this.url = url; this.url = url;
this.headers = headers; this.headers = headers;
this.isRedirect = isRedirect; this.isRedirect = isRedirect;
@ -38,7 +37,7 @@ public class WebResourceRequestExt {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
isRedirect = request.isRedirect(); isRedirect = request.isRedirect();
} }
return new WebResourceRequestExt(request.getUrl(), return new WebResourceRequestExt(request.getUrl().toString(),
request.getRequestHeaders(), request.getRequestHeaders(),
isRedirect, isRedirect,
request.hasGesture(), request.hasGesture(),
@ -49,7 +48,7 @@ public class WebResourceRequestExt {
public Map<String, Object> toMap() { public Map<String, Object> toMap() {
Map<String, Object> webResourceRequestMap = new HashMap<>(); Map<String, Object> webResourceRequestMap = new HashMap<>();
webResourceRequestMap.put("url", url.toString()); webResourceRequestMap.put("url", url);
webResourceRequestMap.put("headers", headers); webResourceRequestMap.put("headers", headers);
webResourceRequestMap.put("isRedirect", isRedirect); webResourceRequestMap.put("isRedirect", isRedirect);
webResourceRequestMap.put("hasGesture", hasGesture); webResourceRequestMap.put("hasGesture", hasGesture);
@ -59,11 +58,11 @@ public class WebResourceRequestExt {
} }
@NonNull @NonNull
public Uri getUrl() { public String getUrl() {
return url; return url;
} }
public void setUrl(@NonNull Uri url) { public void setUrl(@NonNull String url) {
this.url = url; this.url = url;
} }

View File

@ -307,7 +307,7 @@ public class InAppWebViewClient extends WebViewClient {
} }
WebResourceRequestExt request = new WebResourceRequestExt( WebResourceRequestExt request = new WebResourceRequestExt(
Uri.parse(failingUrl), failingUrl,
null, null,
false, false,
false, false,
@ -627,7 +627,8 @@ public class InAppWebViewClient extends WebViewClient {
if (webView.webViewAssetLoaderExt != null && webView.webViewAssetLoaderExt.loader != null) { if (webView.webViewAssetLoaderExt != null && webView.webViewAssetLoaderExt.loader != null) {
try { try {
WebResourceResponse webResourceResponse = webView.webViewAssetLoaderExt.loader.shouldInterceptRequest(request.getUrl()); final Uri uri = Uri.parse(request.getUrl());
WebResourceResponse webResourceResponse = webView.webViewAssetLoaderExt.loader.shouldInterceptRequest(uri);
if (webResourceResponse != null) { if (webResourceResponse != null) {
return webResourceResponse; return webResourceResponse;
} }
@ -667,8 +668,11 @@ public class InAppWebViewClient extends WebViewClient {
return null; return null;
} }
final String url = request.getUrl().toString(); final String url = request.getUrl();
String scheme = request.getUrl().getScheme(); String scheme = url.split(":")[0].toLowerCase();
try {
scheme = Uri.parse(request.getUrl()).getScheme();
} catch (Exception ignored) {}
if (webView.customSettings.resourceCustomSchemes != null && webView.customSettings.resourceCustomSchemes.contains(scheme)) { if (webView.customSettings.resourceCustomSchemes != null && webView.customSettings.resourceCustomSchemes.contains(scheme)) {
CustomSchemeResponse customSchemeResponse = null; CustomSchemeResponse customSchemeResponse = null;
@ -710,7 +714,7 @@ public class InAppWebViewClient extends WebViewClient {
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView view, final String url) { public WebResourceResponse shouldInterceptRequest(WebView view, final String url) {
WebResourceRequestExt requestExt = new WebResourceRequestExt( WebResourceRequestExt requestExt = new WebResourceRequestExt(
Uri.parse(url), null, false, url, null, false,
false, true, "GET" false, true, "GET"
); );
return shouldInterceptRequest(view, requestExt); return shouldInterceptRequest(view, requestExt);

View File

@ -257,6 +257,13 @@ class ExchangeableObjectGenerator
} else if (hasFromValue && deprecatedHasToValue) { } else if (hasFromValue && deprecatedHasToValue) {
classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") +
'.fromValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toValue())${!isNullable ? '!' : ''}'); '.fromValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toValue())${!isNullable ? '!' : ''}');
} else if (deprecatedField.type.getDisplayString(withNullability: false) == "Uri" &&
fieldElement.type.getDisplayString(withNullability: false) == "WebUri") {
if (deprecatedIsNullable) {
classBuffer.write("($deprecatedFieldName != null ? WebUri.uri($deprecatedFieldName!) : ${isNullable ? "null" : "WebUri('')"})");
} else {
classBuffer.write("WebUri.uri($deprecatedFieldName)");
}
} else { } else {
classBuffer.write(deprecatedFieldName); classBuffer.write(deprecatedFieldName);
} }
@ -496,6 +503,12 @@ class ExchangeableObjectGenerator
} else { } else {
return "$value != null ? Uri.tryParse($value) : null"; return "$value != null ? Uri.tryParse($value) : null";
} }
} else if (elementType.getDisplayString(withNullability: false) == "WebUri") {
if (!isNullable) {
return "WebUri($value)";
} else {
return "$value != null ? WebUri($value) : null";
}
} else if (elementType.getDisplayString(withNullability: false) == } else if (elementType.getDisplayString(withNullability: false) ==
"Color") { "Color") {
if (!isNullable) { if (!isNullable) {
@ -573,6 +586,8 @@ class ExchangeableObjectGenerator
final isNullable = Util.typeIsNullable(elementType); final isNullable = Util.typeIsNullable(elementType);
if (elementType.getDisplayString(withNullability: false) == "Uri") { if (elementType.getDisplayString(withNullability: false) == "Uri") {
return fieldName + (isNullable ? '?' : '') + '.toString()'; return fieldName + (isNullable ? '?' : '') + '.toString()';
} else if (elementType.getDisplayString(withNullability: false) == "WebUri") {
return fieldName + (isNullable ? '?' : '') + '.toString()';
} else if (elementType.getDisplayString(withNullability: false) == } else if (elementType.getDisplayString(withNullability: false) ==
"Color") { "Color") {
return fieldName + (isNullable ? '?' : '') + '.toHex()'; return fieldName + (isNullable ? '?' : '') + '.toHex()';

View File

@ -20,7 +20,7 @@ void customTabs() {
await chromeSafariBrowser.open( await chromeSafariBrowser.open(
url: TEST_URL_1, url: TEST_URL_1,
referrer: Uri.parse("android-app://custom-referrer"), referrer: WebUri("android-app://custom-referrer"),
settings: ChromeSafariBrowserSettings(isSingleInstance: true)); settings: ChromeSafariBrowserSettings(isSingleInstance: true));
await expectLater(chromeSafariBrowser.opened.future, completes); await expectLater(chromeSafariBrowser.opened.future, completes);
expect(chromeSafariBrowser.isOpened(), true); expect(chromeSafariBrowser.isOpened(), true);

View File

@ -39,7 +39,7 @@ void openAndClose() {
presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN, presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN,
eventAttribution: UIEventAttribution( eventAttribution: UIEventAttribution(
sourceIdentifier: 4, sourceIdentifier: 4,
destinationURL: Uri.parse("https://shop.example/test.html"), destinationURL: WebUri("https://shop.example/test.html"),
sourceDescription: "Banner ad for Test.", sourceDescription: "Banner ad for Test.",
purchaser: "Shop Example, Inc."), purchaser: "Shop Example, Inc."),
activityButton: ActivityButton( activityButton: ActivityButton(

View File

@ -1,28 +1,30 @@
final TEST_URL_ABOUT_BLANK = Uri.parse('about:blank'); import 'package:flutter_inappwebview/flutter_inappwebview.dart';
final TEST_CROSS_PLATFORM_URL_1 = Uri.parse('https://flutter.dev/');
final TEST_CROSS_PLATFORM_URL_2 = Uri.parse('https://www.bing.com/'); final TEST_URL_ABOUT_BLANK = WebUri('about:blank');
final TEST_URL_1 = Uri.parse('https://github.com/flutter'); final TEST_CROSS_PLATFORM_URL_1 = WebUri('https://flutter.dev/');
final TEST_URL_2 = Uri.parse('https://www.google.com/'); final TEST_CROSS_PLATFORM_URL_2 = WebUri('https://www.bing.com/');
final TEST_URL_1 = WebUri('https://github.com/flutter');
final TEST_URL_2 = WebUri('https://www.google.com/');
final TEST_URL_3 = final TEST_URL_3 =
Uri.parse('https://github.com/pichillilorenzo/flutter_inappwebview'); WebUri('https://github.com/pichillilorenzo/flutter_inappwebview');
final TEST_URL_4 = Uri.parse('https://www.youtube.com/'); final TEST_URL_4 = WebUri('https://www.youtube.com/');
final TEST_URL_EXAMPLE = Uri.parse('https://www.example.com/'); final TEST_URL_EXAMPLE = WebUri('https://www.example.com/');
final TEST_URL_HTTP_EXAMPLE = Uri.parse('http://www.example.com/'); final TEST_URL_HTTP_EXAMPLE = WebUri('http://www.example.com/');
final TEST_URL_404 = Uri.parse('https://google.com/404'); final TEST_URL_404 = WebUri('https://google.com/404');
final TEST_WEB_PLATFORM_BASE_URL = final TEST_WEB_PLATFORM_BASE_URL =
Uri.parse(Uri.base.toString().replaceFirst("/#/", "/")); WebUri(Uri.base.toString().replaceFirst("/#/", "/"));
final TEST_WEB_PLATFORM_URL_1 = final TEST_WEB_PLATFORM_URL_1 =
Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page.html'); WebUri(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page.html');
final TEST_WEB_PLATFORM_URL_2 = final TEST_WEB_PLATFORM_URL_2 =
Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page-2.html'); WebUri(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page-2.html');
final TEST_WEB_PLATFORM_URL_3 = final TEST_WEB_PLATFORM_URL_3 =
Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'heavy-page.html'); WebUri(TEST_WEB_PLATFORM_BASE_URL.toString() + 'heavy-page.html');
final TEST_NOT_A_WEBSITE_URL = Uri.parse('https://www.notawebsite..com/'); final TEST_NOT_A_WEBSITE_URL = WebUri('https://www.notawebsite..com/');
final TEST_CHROME_SAFE_BROWSING_MALWARE = final TEST_CHROME_SAFE_BROWSING_MALWARE =
Uri.parse('chrome://safe-browsing/match?type=malware'); WebUri('chrome://safe-browsing/match?type=malware');
final TEST_PERMISSION_SITE = Uri.parse('https://permission.site/'); final TEST_PERMISSION_SITE = WebUri('https://permission.site/');
final TEST_SERVICE_WORKER_URL = Uri.parse( final TEST_SERVICE_WORKER_URL = WebUri(
'https://mdn.github.io/dom-examples/service-worker/simple-service-worker/'); 'https://mdn.github.io/dom-examples/service-worker/simple-service-worker/');
final TEST_WEBVIEW_ASSET_LOADER_DOMAIN = 'my.custom.domain.com'; final TEST_WEBVIEW_ASSET_LOADER_DOMAIN = 'my.custom.domain.com';
final TEST_WEBVIEW_ASSET_LOADER_URL = Uri.parse( final TEST_WEBVIEW_ASSET_LOADER_URL = WebUri(
'https://$TEST_WEBVIEW_ASSET_LOADER_DOMAIN/assets/flutter_assets/assets/website/index.html'); 'https://$TEST_WEBVIEW_ASSET_LOADER_DOMAIN/assets/flutter_assets/assets/website/index.html');

View File

@ -55,7 +55,7 @@ void setGetDelete() {
); );
} }
final url = Uri.parse(await pageLoaded.future); final url = WebUri(await pageLoaded.future);
await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue"); await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue");
List<Cookie> cookies = await cookieManager.getCookies(url: url); List<Cookie> cookies = await cookieManager.getCookies(url: url);

View File

@ -22,7 +22,7 @@ void loadAssetFile(InAppLocalhostServer localhostServer) {
var headlessWebView = new HeadlessInAppWebView( var headlessWebView = new HeadlessInAppWebView(
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse('http://localhost:8080/test_assets/index.html')), url: WebUri('http://localhost:8080/test_assets/index.html')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -37,7 +37,7 @@ void loadAssetFile(InAppLocalhostServer localhostServer) {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse('http://localhost:8080/test_assets/index.html')), url: WebUri('http://localhost:8080/test_assets/index.html')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },

View File

@ -60,7 +60,7 @@ void audioPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$audioTestBase64')), 'data:text/html;charset=utf-8;base64,$audioTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
@ -96,7 +96,7 @@ void audioPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$audioTestBase64')), 'data:text/html;charset=utf-8;base64,$audioTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);

View File

@ -29,7 +29,7 @@ void getTitle() {
base64Encode(const Utf8Encoder().convert(getTitleTest)); base64Encode(const Utf8Encoder().convert(getTitleTest));
var url = !kIsWeb var url = !kIsWeb
? Uri.parse('data:text/html;charset=utf-8;base64,$getTitleTestBase64') ? WebUri('data:text/html;charset=utf-8;base64,$getTitleTestBase64')
: TEST_WEB_PLATFORM_URL_1; : TEST_WEB_PLATFORM_URL_1;
var expectedValue = !kIsWeb ? 'Some title' : 'page'; var expectedValue = !kIsWeb ? 'Some title' : 'page';

View File

@ -39,8 +39,7 @@ void httpAuthCredentialDatabase() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: url: WebUri("http://${environment["NODE_SERVER_IP"]}:8081/")),
Uri.parse("http://${environment["NODE_SERVER_IP"]}:8081/")),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -95,8 +94,7 @@ void httpAuthCredentialDatabase() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: url: WebUri("http://${environment["NODE_SERVER_IP"]}:8081/")),
Uri.parse("http://${environment["NODE_SERVER_IP"]}:8081/")),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },

View File

@ -84,7 +84,7 @@ void injectCSS() {
await pageLoaded.future; await pageLoaded.future;
await controller.injectCSSFileFromUrl( await controller.injectCSSFileFromUrl(
urlFile: Uri.parse( urlFile: WebUri(
'https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css'), 'https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css'),
cssLinkHtmlTagAttributes: CSSLinkHtmlTagAttributes(id: 'bootstrap')); cssLinkHtmlTagAttributes: CSSLinkHtmlTagAttributes(id: 'bootstrap'));
await Future.delayed(Duration(seconds: 2)); await Future.delayed(Duration(seconds: 2));

View File

@ -47,8 +47,7 @@ void injectJavascriptFile() {
await pageLoaded.future; await pageLoaded.future;
await controller.injectJavascriptFileFromUrl( await controller.injectJavascriptFileFromUrl(
urlFile: urlFile: WebUri('https://www.notawebsite..com/jquery-3.3.1.min.js'),
Uri.parse('https://www.notawebsite..com/jquery-3.3.1.min.js'),
scriptHtmlTagAttributes: ScriptHtmlTagAttributes( scriptHtmlTagAttributes: ScriptHtmlTagAttributes(
id: 'jquery-error', id: 'jquery-error',
onError: () { onError: () {
@ -65,7 +64,7 @@ void injectJavascriptFile() {
true); true);
await controller.injectJavascriptFileFromUrl( await controller.injectJavascriptFileFromUrl(
urlFile: Uri.parse('https://code.jquery.com/jquery-3.3.1.min.js'), urlFile: WebUri('https://code.jquery.com/jquery-3.3.1.min.js'),
scriptHtmlTagAttributes: ScriptHtmlTagAttributes( scriptHtmlTagAttributes: ScriptHtmlTagAttributes(
id: 'jquery', id: 'jquery',
onLoad: () { onLoad: () {

View File

@ -46,7 +46,7 @@ void isSecureContext() {
if (!kIsWeb) { if (!kIsWeb) {
await controller.loadUrl( await controller.loadUrl(
urlRequest: URLRequest(url: Uri.parse('http://example.com/'))); urlRequest: URLRequest(url: WebUri('http://example.com/')));
await pageLoads.stream.first; await pageLoads.stream.first;
expect(await controller.isSecureContext(), false); expect(await controller.isSecureContext(), false);
} }

View File

@ -63,7 +63,7 @@ void loadFileUrl() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: initialUrlRequest:
URLRequest(url: Uri.parse('file://${fileHtml.path}')), URLRequest(url: WebUri('file://${fileHtml.path}')),
onConsoleMessage: (controller, consoleMessage) { onConsoleMessage: (controller, consoleMessage) {
consoleMessageShouldNotComplete.complete(consoleMessage); consoleMessageShouldNotComplete.complete(consoleMessage);
}, },
@ -82,10 +82,9 @@ void loadFileUrl() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: initialUrlRequest:
URLRequest(url: Uri.parse('file://${fileHtml.path}')), URLRequest(url: WebUri('file://${fileHtml.path}')),
initialSettings: InAppWebViewSettings( initialSettings: InAppWebViewSettings(
allowingReadAccessTo: allowingReadAccessTo: WebUri('file://${appSupportDir.path}/')),
Uri.parse('file://${appSupportDir.path}/')),
onConsoleMessage: (controller, consoleMessage) { onConsoleMessage: (controller, consoleMessage) {
consoleMessageCompleter.complete(consoleMessage); consoleMessageCompleter.complete(consoleMessage);
}, },
@ -110,7 +109,7 @@ void loadFileUrl() {
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controller.loadUrl( controller.loadUrl(
urlRequest: urlRequest:
URLRequest(url: Uri.parse('file://${fileHtml.path}'))); URLRequest(url: WebUri('file://${fileHtml.path}')));
}, },
onConsoleMessage: (controller, consoleMessage) { onConsoleMessage: (controller, consoleMessage) {
consoleMessageShouldNotComplete.complete(consoleMessage); consoleMessageShouldNotComplete.complete(consoleMessage);
@ -132,9 +131,9 @@ void loadFileUrl() {
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controller.loadUrl( controller.loadUrl(
urlRequest: urlRequest:
URLRequest(url: Uri.parse('file://${fileHtml.path}')), URLRequest(url: WebUri('file://${fileHtml.path}')),
allowingReadAccessTo: allowingReadAccessTo:
Uri.parse('file://${appSupportDir.path}/')); WebUri('file://${appSupportDir.path}/'));
}, },
onConsoleMessage: (controller, consoleMessage) { onConsoleMessage: (controller, consoleMessage) {
consoleMessageCompleter.complete(consoleMessage); consoleMessageCompleter.complete(consoleMessage);

View File

@ -53,7 +53,7 @@ void onReceivedError() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+')), 'data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+')),
onReceivedError: (controller, request, error) { onReceivedError: (controller, request, error) {
onReceivedErrorCompleter.complete(); onReceivedErrorCompleter.complete();

View File

@ -30,7 +30,7 @@ void postRequests() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
"http://${environment["NODE_SERVER_IP"]}:8082/test-post"), "http://${environment["NODE_SERVER_IP"]}:8082/test-post"),
method: 'POST', method: 'POST',
body: Uint8List.fromList(utf8.encode("name=FooBar")), body: Uint8List.fromList(utf8.encode("name=FooBar")),
@ -68,7 +68,7 @@ void postRequests() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse('about:blank')), initialUrlRequest: URLRequest(url: WebUri('about:blank')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -87,7 +87,7 @@ void postRequests() {
var postData = Uint8List.fromList(utf8.encode("name=FooBar")); var postData = Uint8List.fromList(utf8.encode("name=FooBar"));
await controller.loadUrl( await controller.loadUrl(
urlRequest: URLRequest( urlRequest: URLRequest(
url: Uri.parse( url: WebUri(
"http://${environment["NODE_SERVER_IP"]}:8082/test-post"), "http://${environment["NODE_SERVER_IP"]}:8082/test-post"),
method: 'POST', method: 'POST',
body: postData, body: postData,
@ -114,7 +114,7 @@ void postRequests() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse('about:blank')), initialUrlRequest: URLRequest(url: WebUri('about:blank')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -132,8 +132,7 @@ void postRequests() {
var postData = Uint8List.fromList(utf8.encode("name=FooBar")); var postData = Uint8List.fromList(utf8.encode("name=FooBar"));
await controller.postUrl( await controller.postUrl(
url: Uri.parse( url: WebUri("http://${environment["NODE_SERVER_IP"]}:8082/test-post"),
"http://${environment["NODE_SERVER_IP"]}:8082/test-post"),
postData: postData); postData: postData);
await postPageLoaded.future; await postPageLoaded.future;

View File

@ -52,8 +52,7 @@ void programmaticScroll() {
base64Encode(const Utf8Encoder().convert(scrollTestPage)); base64Encode(const Utf8Encoder().convert(scrollTestPage));
var url = !kIsWeb var url = !kIsWeb
? Uri.parse( ? WebUri('data:text/html;charset=utf-8;base64,$scrollTestPageBase64')
'data:text/html;charset=utf-8;base64,$scrollTestPageBase64')
: TEST_WEB_PLATFORM_URL_1; : TEST_WEB_PLATFORM_URL_1;
final Completer<void> pageLoaded = Completer<void>(); final Completer<void> pageLoaded = Completer<void>();
@ -143,7 +142,7 @@ void programmaticScroll() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$scrollTestPageBase64')), 'data:text/html;charset=utf-8;base64,$scrollTestPageBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);

View File

@ -103,8 +103,7 @@ void programmaticZoomScale() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: initialUrlRequest: URLRequest(url: WebUri('https://flutter.dev')),
URLRequest(url: Uri.parse('https://flutter.dev')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -133,8 +132,7 @@ void programmaticZoomScale() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: initialUrlRequest: URLRequest(url: WebUri('https://flutter.dev')),
URLRequest(url: Uri.parse('https://flutter.dev')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },

View File

@ -44,8 +44,7 @@ void resizeWebView() {
final InAppWebView webView = InAppWebView( final InAppWebView webView = InAppWebView(
key: key, key: key,
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri('data:text/html;charset=utf-8;base64,$resizeTestBase64')),
'data:text/html;charset=utf-8;base64,$resizeTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);

View File

@ -33,7 +33,7 @@ void shouldOverrideUrlLoading() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse(pageEncoded)), initialUrlRequest: URLRequest(url: WebUri(pageEncoded)),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -86,7 +86,7 @@ void shouldOverrideUrlLoading() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse(pageEncoded)), initialUrlRequest: URLRequest(url: WebUri(pageEncoded)),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -145,7 +145,7 @@ void shouldOverrideUrlLoading() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse(pageEncoded)), initialUrlRequest: URLRequest(url: WebUri(pageEncoded)),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
@ -197,7 +197,7 @@ void shouldOverrideUrlLoading() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse(pageEncoded)), initialUrlRequest: URLRequest(url: WebUri(pageEncoded)),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },

View File

@ -26,7 +26,7 @@ void sslRequest() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse("https://${environment["NODE_SERVER_IP"]}:4433/")), url: WebUri("https://${environment["NODE_SERVER_IP"]}:4433/")),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },

View File

@ -68,7 +68,7 @@ void videoPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$videoTestBase64')), 'data:text/html;charset=utf-8;base64,$videoTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
@ -99,7 +99,7 @@ void videoPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$videoTestBase64')), 'data:text/html;charset=utf-8;base64,$videoTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
@ -141,7 +141,7 @@ void videoPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$videoTestBase64')), 'data:text/html;charset=utf-8;base64,$videoTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
@ -185,7 +185,7 @@ void videoPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$videoTestBase64')), 'data:text/html;charset=utf-8;base64,$videoTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
@ -230,7 +230,7 @@ void videoPlaybackPolicy() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$videoTestBase64')), 'data:text/html;charset=utf-8;base64,$videoTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);

View File

@ -72,7 +72,7 @@ void webMessage() {
}); });
await controller.postWebMessage( await controller.postWebMessage(
message: WebMessage(data: "capturePort", ports: [port2]), message: WebMessage(data: "capturePort", ports: [port2]),
targetOrigin: Uri.parse("*")); targetOrigin: WebUri("*"));
await controller.evaluateJavascript( await controller.evaluateJavascript(
source: "document.getElementById('button').click();"); source: "document.getElementById('button').click();");
}, },

View File

@ -278,7 +278,7 @@ void webViewWindows() {
child: InAppWebView( child: InAppWebView(
key: GlobalKey(), key: GlobalKey(),
initialUrlRequest: URLRequest( initialUrlRequest: URLRequest(
url: Uri.parse( url: WebUri(
'data:text/html;charset=utf-8;base64,$openWindowTestBase64')), 'data:text/html;charset=utf-8;base64,$openWindowTestBase64')),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);

View File

@ -44,7 +44,7 @@ class MyInAppBrowser extends InAppBrowser {
} }
@override @override
void onLoadStop(Uri? url) { void onLoadStop(WebUri? url) {
super.onLoadStop(url); super.onLoadStop(url);
if (!firstPageLoaded.isCompleted) { if (!firstPageLoaded.isCompleted) {

View File

@ -78,7 +78,7 @@ class _ChromeSafariBrowserExampleScreenState
child: ElevatedButton( child: ElevatedButton(
onPressed: () async { onPressed: () async {
await widget.browser.open( await widget.browser.open(
url: Uri.parse("https://flutter.dev/"), url: WebUri("https://flutter.dev/"),
settings: ChromeSafariBrowserSettings( settings: ChromeSafariBrowserSettings(
shareState: CustomTabsShareState.SHARE_STATE_OFF, shareState: CustomTabsShareState.SHARE_STATE_OFF,
isSingleInstance: false, isSingleInstance: false,

View File

@ -20,8 +20,8 @@ class _HeadlessInAppWebViewExampleScreenState
super.initState(); super.initState();
var url = !kIsWeb var url = !kIsWeb
? Uri.parse("https://flutter.dev") ? WebUri("https://flutter.dev")
: Uri.parse("http://localhost:${Uri.base.port}/page.html"); : WebUri("http://localhost:${Uri.base.port}/page.html");
headlessWebView = new HeadlessInAppWebView( headlessWebView = new HeadlessInAppWebView(
initialUrlRequest: URLRequest(url: url), initialUrlRequest: URLRequest(url: url),

View File

@ -109,7 +109,7 @@ class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
onPressed: () async { onPressed: () async {
await widget.browser.openUrlRequest( await widget.browser.openUrlRequest(
urlRequest: urlRequest:
URLRequest(url: Uri.parse("https://flutter.dev")), URLRequest(url: WebUri("https://flutter.dev")),
settings: InAppBrowserClassSettings( settings: InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings( browserSettings: InAppBrowserSettings(
toolbarTopBackgroundColor: Colors.blue, toolbarTopBackgroundColor: Colors.blue,
@ -126,7 +126,7 @@ class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
await InAppBrowser.openWithSystemBrowser( await InAppBrowser.openWithSystemBrowser(
url: Uri.parse("https://flutter.dev/")); url: WebUri("https://flutter.dev/"));
}, },
child: Text("Open System Browser")), child: Text("Open System Browser")),
]))); ])));

View File

@ -99,9 +99,9 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
controller: urlController, controller: urlController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
onSubmitted: (value) { onSubmitted: (value) {
var url = Uri.parse(value); var url = WebUri(value);
if (url.scheme.isEmpty) { if (url.scheme.isEmpty) {
url = Uri.parse((!kIsWeb url = WebUri((!kIsWeb
? "https://www.google.com/search?q=" ? "https://www.google.com/search?q="
: "https://www.bing.com/search?q=") + : "https://www.bing.com/search?q=") +
value); value);
@ -115,9 +115,9 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
InAppWebView( InAppWebView(
key: webViewKey, key: webViewKey,
initialUrlRequest: initialUrlRequest:
URLRequest(url: Uri.parse('https://flutter.dev')), URLRequest(url: WebUri('https://flutter.dev')),
// initialUrlRequest: // initialUrlRequest:
// URLRequest(url: Uri.parse(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')), // URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
// initialFile: "assets/index.html", // initialFile: "assets/index.html",
initialUserScripts: UnmodifiableListView<UserScript>([]), initialUserScripts: UnmodifiableListView<UserScript>([]),
initialSettings: settings, initialSettings: settings,

View File

@ -10,10 +10,12 @@ import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart'; import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart';
import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart'; import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart';
// import 'package:path_provider/path_provider.dart'; // import 'package:path_provider/path_provider.dart';
// import 'package:permission_handler/permission_handler.dart'; // import 'package:permission_handler/permission_handler.dart';
InAppLocalhostServer localhostServer = new InAppLocalhostServer(documentRoot: 'assets'); InAppLocalhostServer localhostServer =
new InAppLocalhostServer(documentRoot: 'assets');
Future main() async { Future main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -148,14 +150,16 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(initialRoute: '/', routes: { return MaterialApp(initialRoute: '/', routes: {
'/': (context) => InAppWebViewExampleScreen(), '/': (context) => InAppWebViewExampleScreen(),
}); });
} }f
if (defaultTargetPlatform == TargetPlatform.macOS) { if (defaultTargetPlatform == TargetPlatform.macOS) {
return MaterialApp(initialRoute: '/', routes: { return MaterialApp(initialRoute: '/', routes: {
// '/': (context) => InAppWebViewExampleScreen(), // '/': (context) => InAppWebViewExampleScreen(),
// '/InAppBrowser': (context) => InAppBrowserExampleScreen(), // '/InAppBrowser': (context) => InAppBrowserExampleScreen(),
'/': (context) => InAppBrowserExampleScreen(), '/': (context) => InAppBrowserExampleScreen(),
'/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(), '/HeadlessInAppWebView': (context) =>
'/WebAuthenticationSession': (context) => WebAuthenticationSessionExampleScreen(), HeadlessInAppWebViewExampleScreen(),
'/WebAuthenticationSession': (context) =>
WebAuthenticationSessionExampleScreen(),
}); });
} }
return MaterialApp(initialRoute: '/', routes: { return MaterialApp(initialRoute: '/', routes: {
@ -163,7 +167,8 @@ class _MyAppState extends State<MyApp> {
'/InAppBrowser': (context) => InAppBrowserExampleScreen(), '/InAppBrowser': (context) => InAppBrowserExampleScreen(),
'/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(), '/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(),
'/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(), '/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(),
'/WebAuthenticationSession': (context) => WebAuthenticationSessionExampleScreen(), '/WebAuthenticationSession': (context) =>
WebAuthenticationSessionExampleScreen(),
}); });
} }
} }

View File

@ -52,7 +52,7 @@ class _WebAuthenticationSessionExampleScreenState
.contains(defaultTargetPlatform) && .contains(defaultTargetPlatform) &&
await WebAuthenticationSession.isAvailable()) { await WebAuthenticationSession.isAvailable()) {
session = await WebAuthenticationSession.create( session = await WebAuthenticationSession.create(
url: Uri.parse( url: WebUri(
"http://localhost:8080/web-auth.html"), "http://localhost:8080/web-auth.html"),
callbackURLScheme: "test", callbackURLScheme: "test",
onComplete: (url, error) async { onComplete: (url, error) async {

View File

@ -12,6 +12,7 @@ import '../types/ui_image.dart';
import '../util.dart'; import '../util.dart';
import '../debug_logging_settings.dart'; import '../debug_logging_settings.dart';
import '../web_uri.dart';
import 'chrome_safari_browser_settings.dart'; import 'chrome_safari_browser_settings.dart';
class ChromeSafariBrowserAlreadyOpenedException implements Exception { class ChromeSafariBrowserAlreadyOpenedException implements Exception {
@ -103,7 +104,7 @@ class ChromeSafariBrowser {
break; break;
case "onInitialLoadDidRedirect": case "onInitialLoadDidRedirect":
final String? url = call.arguments["url"]; final String? url = call.arguments["url"];
final Uri? uri = url != null ? Uri.tryParse(url) : null; final WebUri? uri = url != null ? WebUri(url) : null;
onInitialLoadDidRedirect(uri); onInitialLoadDidRedirect(uri);
break; break;
case "onNavigationEvent": case "onNavigationEvent":
@ -115,7 +116,7 @@ class ChromeSafariBrowser {
final relation = final relation =
CustomTabsRelationType.fromNativeValue(call.arguments["relation"]); CustomTabsRelationType.fromNativeValue(call.arguments["relation"]);
final requestedOrigin = call.arguments["requestedOrigin"] != null final requestedOrigin = call.arguments["requestedOrigin"] != null
? Uri.tryParse(call.arguments["requestedOrigin"]) ? WebUri(call.arguments["requestedOrigin"])
: null; : null;
final bool result = call.arguments["result"]; final bool result = call.arguments["result"];
onRelationshipValidationResult(relation, requestedOrigin, result); onRelationshipValidationResult(relation, requestedOrigin, result);
@ -136,22 +137,22 @@ class ChromeSafariBrowser {
this._actionButton?.action!(url, title); this._actionButton?.action!(url, title);
} }
if (this._actionButton?.onClick != null) { if (this._actionButton?.onClick != null) {
this._actionButton?.onClick!(Uri.tryParse(url), title); this._actionButton?.onClick!(WebUri(url), title);
} }
} else if (this._menuItems[id] != null) { } else if (this._menuItems[id] != null) {
if (this._menuItems[id]?.action != null) { if (this._menuItems[id]?.action != null) {
this._menuItems[id]?.action!(url, title); this._menuItems[id]?.action!(url, title);
} }
if (this._menuItems[id]?.onClick != null) { if (this._menuItems[id]?.onClick != null) {
this._menuItems[id]?.onClick!(Uri.tryParse(url), title); this._menuItems[id]?.onClick!(WebUri(url), title);
} }
} }
break; break;
case "onSecondaryItemActionPerform": case "onSecondaryItemActionPerform":
final clickableIDs = this._secondaryToolbar?.clickableIDs; final clickableIDs = this._secondaryToolbar?.clickableIDs;
if (clickableIDs != null) { if (clickableIDs != null) {
Uri? url = call.arguments["url"] != null WebUri? url = call.arguments["url"] != null
? Uri.tryParse(call.arguments["url"]) ? WebUri(call.arguments["url"])
: null; : null;
String name = call.arguments["name"]; String name = call.arguments["name"];
for (final clickable in clickableIDs) { for (final clickable in clickableIDs) {
@ -199,10 +200,10 @@ class ChromeSafariBrowser {
///- Android ///- Android
///- iOS ///- iOS
Future<void> open( Future<void> open(
{Uri? url, {WebUri? url,
Map<String, String>? headers, Map<String, String>? headers,
List<Uri>? otherLikelyURLs, List<WebUri>? otherLikelyURLs,
Uri? referrer, WebUri? referrer,
@Deprecated('Use settings instead') @Deprecated('Use settings instead')
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
ChromeSafariBrowserClassOptions? options, ChromeSafariBrowserClassOptions? options,
@ -257,10 +258,10 @@ class ChromeSafariBrowser {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android ///- Android
Future<void> launchUrl({ Future<void> launchUrl({
required Uri url, required WebUri url,
Map<String, String>? headers, Map<String, String>? headers,
List<Uri>? otherLikelyURLs, List<WebUri>? otherLikelyURLs,
Uri? referrer, WebUri? referrer,
}) async { }) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
@ -283,7 +284,8 @@ class ChromeSafariBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E)))
Future<bool> mayLaunchUrl({Uri? url, List<Uri>? otherLikelyURLs}) async { Future<bool> mayLaunchUrl(
{WebUri? url, List<WebUri>? otherLikelyURLs}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url?.toString()); args.putIfAbsent('url', () => url?.toString());
args.putIfAbsent('otherLikelyURLs', args.putIfAbsent('otherLikelyURLs',
@ -308,7 +310,8 @@ class ChromeSafariBrowser {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle)))
Future<bool> validateRelationship( Future<bool> validateRelationship(
{required CustomTabsRelationType relation, required Uri origin}) async { {required CustomTabsRelationType relation,
required WebUri origin}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('relation', () => relation.toNativeValue()); args.putIfAbsent('relation', () => relation.toNativeValue());
args.putIfAbsent('origin', () => origin.toString()); args.putIfAbsent('origin', () => origin.toString());
@ -453,7 +456,7 @@ class ChromeSafariBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections))
static Future<PrewarmingToken?> prewarmConnections(List<Uri> URLs) async { static Future<PrewarmingToken?> prewarmConnections(List<WebUri> URLs) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList());
Map<String, dynamic>? result = Map<String, dynamic>? result =
@ -501,7 +504,7 @@ class ChromeSafariBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller)) ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller))
void onInitialLoadDidRedirect(Uri? url) {} void onInitialLoadDidRedirect(WebUri? url) {}
///Event fired when a navigation event happens. ///Event fired when a navigation event happens.
/// ///
@ -520,7 +523,7 @@ class ChromeSafariBrowser {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle))) ///- Android ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle)))
void onRelationshipValidationResult( void onRelationshipValidationResult(
CustomTabsRelationType? relation, Uri? requestedOrigin, bool result) {} CustomTabsRelationType? relation, WebUri? requestedOrigin, bool result) {}
///Event fired when the user opens the current page in the default browser by tapping the toolbar button. ///Event fired when the user opens the current page in the default browser by tapping the toolbar button.
/// ///
@ -587,7 +590,7 @@ class ChromeSafariBrowserActionButton {
void Function(String url, String title)? action; void Function(String url, String title)? action;
///Callback function to be invoked when the action button is clicked ///Callback function to be invoked when the action button is clicked
void Function(Uri? url, String title)? onClick; void Function(WebUri? url, String title)? onClick;
ChromeSafariBrowserActionButton( ChromeSafariBrowserActionButton(
{required this.id, {required this.id,
@ -638,7 +641,7 @@ class ChromeSafariBrowserMenuItem {
void Function(String url, String title)? action; void Function(String url, String title)? action;
///Callback function to be invoked when the menu item is clicked ///Callback function to be invoked when the menu item is clicked
void Function(Uri? url, String title)? onClick; void Function(WebUri? url, String title)? onClick;
ChromeSafariBrowserMenuItem( ChromeSafariBrowserMenuItem(
{required this.id, {required this.id,
@ -712,7 +715,7 @@ class ChromeSafariBrowserSecondaryToolbarClickableID {
AndroidResource id; AndroidResource id;
///Callback function to be invoked when the item is clicked ///Callback function to be invoked when the item is clicked
void Function(Uri? url)? onClick; void Function(WebUri? url)? onClick;
ChromeSafariBrowserSecondaryToolbarClickableID( ChromeSafariBrowserSecondaryToolbarClickableID(
{required this.id, this.onClick}); {required this.id, this.onClick});

View File

@ -8,6 +8,7 @@ import 'in_app_webview/headless_in_app_webview.dart';
import 'platform_util.dart'; import 'platform_util.dart';
import 'types/main.dart'; import 'types/main.dart';
import 'web_uri.dart';
///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances. ///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances.
///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). ///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager).
@ -76,7 +77,7 @@ class CookieManager {
///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) ///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
///- Web ///- Web
Future<void> setCookie( Future<void> setCookie(
{required Uri url, {required WebUri url,
required String name, required String name,
required String value, required String value,
String path = "/", String path = "/",
@ -127,7 +128,7 @@ class CookieManager {
} }
Future<void> _setCookieWithJavaScript( Future<void> _setCookieWithJavaScript(
{required Uri url, {required WebUri url,
required String name, required String name,
required String value, required String value,
String path = "/", String path = "/",
@ -197,7 +198,7 @@ class CookieManager {
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- Web ///- Web
Future<List<Cookie>> getCookies( Future<List<Cookie>> getCookies(
{required Uri url, {required WebUri url,
@Deprecated("Use webViewController instead") @Deprecated("Use webViewController instead")
InAppWebViewController? iosBelow11WebViewController, InAppWebViewController? iosBelow11WebViewController,
InAppWebViewController? webViewController}) async { InAppWebViewController? webViewController}) async {
@ -235,7 +236,7 @@ class CookieManager {
} }
Future<List<Cookie>> _getCookiesWithJavaScript( Future<List<Cookie>> _getCookiesWithJavaScript(
{required Uri url, InAppWebViewController? webViewController}) async { {required WebUri url, InAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty); assert(url.toString().isNotEmpty);
List<Cookie> cookies = []; List<Cookie> cookies = [];
@ -310,7 +311,7 @@ class CookieManager {
///- MacOS ///- MacOS
///- Web ///- Web
Future<Cookie?> getCookie( Future<Cookie?> getCookie(
{required Uri url, {required WebUri url,
required String name, required String name,
@Deprecated("Use webViewController instead") @Deprecated("Use webViewController instead")
InAppWebViewController? iosBelow11WebViewController, InAppWebViewController? iosBelow11WebViewController,
@ -371,7 +372,7 @@ class CookieManager {
///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) ///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
///- Web ///- Web
Future<void> deleteCookie( Future<void> deleteCookie(
{required Uri url, {required WebUri url,
required String name, required String name,
String path = "/", String path = "/",
String? domain, String? domain,
@ -424,7 +425,7 @@ class CookieManager {
///- MacOS ///- MacOS
///- Web ///- Web
Future<void> deleteCookies( Future<void> deleteCookies(
{required Uri url, {required WebUri url,
String path = "/", String path = "/",
String? domain, String? domain,
@Deprecated("Use webViewController instead") @Deprecated("Use webViewController instead")

View File

@ -14,6 +14,7 @@ import '../in_app_webview/in_app_webview_settings.dart';
import '../util.dart'; import '../util.dart';
import '../print_job/main.dart'; import '../print_job/main.dart';
import '../web_uri.dart';
import 'in_app_browser_settings.dart'; import 'in_app_browser_settings.dart';
import '../debug_logging_settings.dart'; import '../debug_logging_settings.dart';
@ -271,9 +272,9 @@ class InAppBrowser {
{required String data, {required String data,
String mimeType = "text/html", String mimeType = "text/html",
String encoding = "utf8", String encoding = "utf8",
Uri? baseUrl, WebUri? baseUrl,
@Deprecated("Use historyUrl instead") Uri? androidHistoryUrl, @Deprecated("Use historyUrl instead") Uri? androidHistoryUrl,
Uri? historyUrl, WebUri? historyUrl,
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options, @Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async { InAppBrowserClassSettings? settings}) async {
@ -313,7 +314,7 @@ class InAppBrowser {
///- Android native WebView ///- Android native WebView
///- iOS ///- iOS
///- MacOS ///- MacOS
static Future<void> openWithSystemBrowser({required Uri url}) async { static Future<void> openWithSystemBrowser({required WebUri url}) async {
assert(url.toString().isNotEmpty); assert(url.toString().isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
@ -462,7 +463,7 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap))) ///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
void onLoadStart(Uri? url) {} void onLoadStart(WebUri? url) {}
///Event fired when the [InAppBrowser] finishes loading an [url]. ///Event fired when the [InAppBrowser] finishes loading an [url].
/// ///
@ -470,7 +471,7 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String))) ///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
void onLoadStop(Uri? url) {} void onLoadStop(WebUri? url) {}
///Use [onReceivedError] instead. ///Use [onReceivedError] instead.
@Deprecated("Use onReceivedError instead") @Deprecated("Use onReceivedError instead")
@ -839,7 +840,7 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)))
///- iOS ///- iOS
///- MacOS ///- MacOS
void onUpdateVisitedHistory(Uri? url, bool? isReload) {} void onUpdateVisitedHistory(WebUri? url, bool? isReload) {}
///Use [onPrintRequest] instead ///Use [onPrintRequest] instead
@Deprecated("Use onPrintRequest instead") @Deprecated("Use onPrintRequest instead")
@ -858,7 +859,7 @@ class InAppBrowser {
///- iOS ///- iOS
///- MacOS ///- MacOS
Future<bool?>? onPrintRequest( Future<bool?>? onPrintRequest(
Uri? url, PrintJobController? printJobController) { WebUri? url, PrintJobController? printJobController) {
return null; return null;
} }
@ -898,7 +899,7 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String))) ///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
void onPageCommitVisible(Uri? url) {} void onPageCommitVisible(WebUri? url) {}
///Event fired when a change in the document title occurred. ///Event fired when a change in the document title occurred.
/// ///
@ -955,7 +956,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)))
Future<SafeBrowsingResponse?>? onSafeBrowsingHit( Future<SafeBrowsingResponse?>? onSafeBrowsingHit(
Uri url, SafeBrowsingThreat? threatType) { WebUri url, SafeBrowsingThreat? threatType) {
return null; return null;
} }
@ -1072,7 +1073,8 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive(Uri? url) { Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive(
WebUri? url) {
return null; return null;
} }
@ -1095,7 +1097,7 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
Future<WebViewRenderProcessAction?>? onRenderProcessResponsive(Uri? url) { Future<WebViewRenderProcessAction?>? onRenderProcessResponsive(WebUri? url) {
return null; return null;
} }
@ -1125,7 +1127,7 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)))
Future<FormResubmissionAction?>? onFormResubmission(Uri? url) { Future<FormResubmissionAction?>? onFormResubmission(WebUri? url) {
return null; return null;
} }
@ -1157,7 +1159,7 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)))
void onReceivedTouchIconUrl(Uri url, bool precomposed) {} void onReceivedTouchIconUrl(WebUri url, bool precomposed) {}
///Use [onJsBeforeUnload] instead. ///Use [onJsBeforeUnload] instead.
@Deprecated('Use onJsBeforeUnload instead') @Deprecated('Use onJsBeforeUnload instead')

View File

@ -9,6 +9,7 @@ import '../context_menu.dart';
import '../find_interaction/find_interaction_controller.dart'; import '../find_interaction/find_interaction_controller.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../print_job/main.dart'; import '../print_job/main.dart';
import '../web_uri.dart';
import 'webview.dart'; import 'webview.dart';
import 'in_app_webview_controller.dart'; import 'in_app_webview_controller.dart';
import 'in_app_webview_settings.dart'; import 'in_app_webview_settings.dart';
@ -364,7 +365,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit;
@override @override
void Function(InAppWebViewController controller, Uri? url)? void Function(InAppWebViewController controller, WebUri? url)?
onPageCommitVisible; onPageCommitVisible;
@override @override
@ -490,10 +491,10 @@ class HeadlessInAppWebView implements WebView, Disposable {
onLoadResourceWithCustomScheme; onLoadResourceWithCustomScheme;
@override @override
void Function(InAppWebViewController controller, Uri? url)? onLoadStart; void Function(InAppWebViewController controller, WebUri? url)? onLoadStart;
@override @override
void Function(InAppWebViewController controller, Uri? url)? onLoadStop; void Function(InAppWebViewController controller, WebUri? url)? onLoadStop;
@override @override
void Function(InAppWebViewController controller, void Function(InAppWebViewController controller,
@ -505,7 +506,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
void Function(InAppWebViewController controller, Uri? url)? onPrint; void Function(InAppWebViewController controller, Uri? url)? onPrint;
@override @override
Future<bool?> Function(InAppWebViewController controller, Uri? url, Future<bool?> Function(InAppWebViewController controller, WebUri? url,
PrintJobController? printJobController)? onPrintRequest; PrintJobController? printJobController)? onPrintRequest;
@override @override
@ -529,7 +530,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
onScrollChanged; onScrollChanged;
@override @override
void Function(InAppWebViewController controller, Uri? url, bool? isReload)? void Function(InAppWebViewController controller, WebUri? url, bool? isReload)?
onUpdateVisitedHistory; onUpdateVisitedHistory;
@override @override
@ -636,7 +637,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
@override @override
Future<FormResubmissionAction?> Function( Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission; InAppWebViewController controller, WebUri? url)? onFormResubmission;
@override @override
void Function(InAppWebViewController controller)? void Function(InAppWebViewController controller)?
@ -668,7 +669,8 @@ class HeadlessInAppWebView implements WebView, Disposable {
onReceivedLoginRequest; onReceivedLoginRequest;
@override @override
void Function(InAppWebViewController controller, Uri url, bool precomposed)? void Function(
InAppWebViewController controller, WebUri url, bool precomposed)?
onReceivedTouchIconUrl; onReceivedTouchIconUrl;
@override @override
@ -678,15 +680,17 @@ class HeadlessInAppWebView implements WebView, Disposable {
@override @override
Future<WebViewRenderProcessAction?> Function( Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessResponsive;
@override @override
Future<WebViewRenderProcessAction?> Function( Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessUnresponsive;
@override @override
Future<SafeBrowsingResponse?> Function(InAppWebViewController controller, Future<SafeBrowsingResponse?> Function(InAppWebViewController controller,
Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit; WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override @override
void Function(InAppWebViewController controller)? void Function(InAppWebViewController controller)?

View File

@ -18,6 +18,7 @@ import '../context_menu.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../print_job/main.dart'; import '../print_job/main.dart';
import '../web_uri.dart';
import 'webview.dart'; import 'webview.dart';
import 'in_app_webview_controller.dart'; import 'in_app_webview_controller.dart';
import 'in_app_webview_settings.dart'; import 'in_app_webview_settings.dart';
@ -231,7 +232,7 @@ class InAppWebView extends StatefulWidget implements WebView {
final ContextMenu? contextMenu; final ContextMenu? contextMenu;
@override @override
final void Function(InAppWebViewController controller, Uri? url)? final void Function(InAppWebViewController controller, WebUri? url)?
onPageCommitVisible; onPageCommitVisible;
@override @override
@ -375,10 +376,12 @@ class InAppWebView extends StatefulWidget implements WebView {
onLoadResourceWithCustomScheme; onLoadResourceWithCustomScheme;
@override @override
final void Function(InAppWebViewController controller, Uri? url)? onLoadStart; final void Function(InAppWebViewController controller, WebUri? url)?
onLoadStart;
@override @override
final void Function(InAppWebViewController controller, Uri? url)? onLoadStop; final void Function(InAppWebViewController controller, WebUri? url)?
onLoadStop;
@override @override
final void Function(InAppWebViewController controller, final void Function(InAppWebViewController controller,
@ -390,7 +393,7 @@ class InAppWebView extends StatefulWidget implements WebView {
final void Function(InAppWebViewController controller, Uri? url)? onPrint; final void Function(InAppWebViewController controller, Uri? url)? onPrint;
@override @override
final Future<bool?> Function(InAppWebViewController controller, Uri? url, final Future<bool?> Function(InAppWebViewController controller, WebUri? url,
PrintJobController? printJobController)? onPrintRequest; PrintJobController? printJobController)? onPrintRequest;
@override @override
@ -416,7 +419,7 @@ class InAppWebView extends StatefulWidget implements WebView {
@override @override
final void Function( final void Function(
InAppWebViewController controller, Uri? url, bool? isReload)? InAppWebViewController controller, WebUri? url, bool? isReload)?
onUpdateVisitedHistory; onUpdateVisitedHistory;
@override @override
@ -513,7 +516,7 @@ class InAppWebView extends StatefulWidget implements WebView {
@override @override
final Future<FormResubmissionAction?> Function( final Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission; InAppWebViewController controller, WebUri? url)? onFormResubmission;
@override @override
final void Function(InAppWebViewController controller)? final void Function(InAppWebViewController controller)?
@ -549,7 +552,7 @@ class InAppWebView extends StatefulWidget implements WebView {
@override @override
final void Function( final void Function(
InAppWebViewController controller, Uri url, bool precomposed)? InAppWebViewController controller, WebUri url, bool precomposed)?
onReceivedTouchIconUrl; onReceivedTouchIconUrl;
@override @override
@ -559,16 +562,18 @@ class InAppWebView extends StatefulWidget implements WebView {
@override @override
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessResponsive;
@override @override
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessUnresponsive;
@override @override
final Future<SafeBrowsingResponse?> Function( final Future<SafeBrowsingResponse?> Function(
InAppWebViewController controller, InAppWebViewController controller,
Uri url, WebUri url,
SafeBrowsingThreat? threatType)? onSafeBrowsingHit; SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override @override

View File

@ -9,6 +9,7 @@ import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import '../web_uri.dart';
import 'android/in_app_webview_controller.dart'; import 'android/in_app_webview_controller.dart';
import 'apple/in_app_webview_controller.dart'; import 'apple/in_app_webview_controller.dart';
@ -134,7 +135,7 @@ class InAppWebViewController {
if ((_webview != null && _webview!.onLoadStart != null) || if ((_webview != null && _webview!.onLoadStart != null) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null && _webview!.onLoadStart != null) if (_webview != null && _webview!.onLoadStart != null)
_webview!.onLoadStart!(this, uri); _webview!.onLoadStart!(this, uri);
else else
@ -145,7 +146,7 @@ class InAppWebViewController {
if ((_webview != null && _webview!.onLoadStop != null) || if ((_webview != null && _webview!.onLoadStop != null) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null && _webview!.onLoadStop != null) if (_webview != null && _webview!.onLoadStop != null)
_webview!.onLoadStop!(this, uri); _webview!.onLoadStop!(this, uri);
else else
@ -435,7 +436,7 @@ class InAppWebViewController {
_webview!.androidOnRenderProcessUnresponsive != null)) || _webview!.androidOnRenderProcessUnresponsive != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null) { if (_webview != null) {
if (_webview!.onRenderProcessUnresponsive != null) if (_webview!.onRenderProcessUnresponsive != null)
@ -463,7 +464,7 @@ class InAppWebViewController {
_webview!.androidOnRenderProcessResponsive != null)) || _webview!.androidOnRenderProcessResponsive != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null) { if (_webview != null) {
if (_webview!.onRenderProcessResponsive != null) if (_webview!.onRenderProcessResponsive != null)
@ -516,7 +517,7 @@ class InAppWebViewController {
_webview!.androidOnFormResubmission != null)) || _webview!.androidOnFormResubmission != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null) { if (_webview != null) {
if (_webview!.onFormResubmission != null) if (_webview!.onFormResubmission != null)
@ -589,7 +590,7 @@ class InAppWebViewController {
_inAppBrowser != null) { _inAppBrowser != null) {
String url = call.arguments["url"]; String url = call.arguments["url"];
bool precomposed = call.arguments["precomposed"]; bool precomposed = call.arguments["precomposed"];
Uri uri = Uri.tryParse(url) ?? Uri(); WebUri uri = WebUri(url);
if (_webview != null) { if (_webview != null) {
if (_webview!.onReceivedTouchIconUrl != null) if (_webview!.onReceivedTouchIconUrl != null)
@ -689,7 +690,7 @@ class InAppWebViewController {
String url = call.arguments["url"]; String url = call.arguments["url"];
SafeBrowsingThreat? threatType = SafeBrowsingThreat? threatType =
SafeBrowsingThreat.fromNativeValue(call.arguments["threatType"]); SafeBrowsingThreat.fromNativeValue(call.arguments["threatType"]);
Uri uri = Uri.tryParse(url) ?? Uri(); WebUri uri = WebUri(url);
if (_webview != null) { if (_webview != null) {
if (_webview!.onSafeBrowsingHit != null) if (_webview!.onSafeBrowsingHit != null)
@ -867,7 +868,7 @@ class InAppWebViewController {
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
bool? isReload = call.arguments["isReload"]; bool? isReload = call.arguments["isReload"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null && _webview!.onUpdateVisitedHistory != null) if (_webview != null && _webview!.onUpdateVisitedHistory != null)
_webview!.onUpdateVisitedHistory!(this, uri, isReload); _webview!.onUpdateVisitedHistory!(this, uri, isReload);
else else
@ -895,7 +896,7 @@ class InAppWebViewController {
if ((_webview != null && _webview!.onPageCommitVisible != null) || if ((_webview != null && _webview!.onPageCommitVisible != null) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
if (_webview != null && _webview!.onPageCommitVisible != null) if (_webview != null && _webview!.onPageCommitVisible != null)
_webview!.onPageCommitVisible!(this, uri); _webview!.onPageCommitVisible!(this, uri);
else else
@ -1120,7 +1121,7 @@ class InAppWebViewController {
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
String? printJobId = call.arguments["printJobId"]; String? printJobId = call.arguments["printJobId"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
PrintJobController? printJob = PrintJobController? printJob =
printJobId != null ? PrintJobController(id: printJobId) : null; printJobId != null ? PrintJobController(id: printJobId) : null;
@ -1330,10 +1331,10 @@ class InAppWebViewController {
///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) ///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) ///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- Web ///- Web
Future<Uri?> getUrl() async { Future<WebUri?> getUrl() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
String? url = await _channel.invokeMethod('getUrl', args); String? url = await _channel.invokeMethod('getUrl', args);
return url != null ? Uri.tryParse(url) : null; return url != null ? WebUri(url) : null;
} }
///Gets the title for the current page. ///Gets the title for the current page.
@ -1493,7 +1494,7 @@ class InAppWebViewController {
HttpClient client = HttpClient(); HttpClient client = HttpClient();
var faviconUrl = var faviconUrl =
webviewUrl.scheme + "://" + webviewUrl.host + "/favicon.ico"; webviewUrl.scheme + "://" + webviewUrl.host + "/favicon.ico";
var faviconUri = Uri.parse(faviconUrl); var faviconUri = WebUri(faviconUrl);
var headRequest = await client.headUrl(faviconUri); var headRequest = await client.headUrl(faviconUri);
var headResponse = await headRequest.close(); var headResponse = await headRequest.close();
if (headResponse.statusCode == 200) { if (headResponse.statusCode == 200) {
@ -1546,8 +1547,8 @@ class InAppWebViewController {
return url.startsWith("http://") || url.startsWith("https://"); return url.startsWith("http://") || url.startsWith("https://");
} }
List<Favicon> _createFavicons(Uri url, String? assetPathBase, String urlIcon, List<Favicon> _createFavicons(WebUri url, String? assetPathBase,
String? rel, String? sizes, bool isManifest) { String urlIcon, String? rel, String? sizes, bool isManifest) {
List<Favicon> favicons = []; List<Favicon> favicons = [];
List<String> urlSplitted = urlIcon.split("/"); List<String> urlSplitted = urlIcon.split("/");
@ -1574,17 +1575,11 @@ class InAppWebViewController {
int width = int.parse(size.split("x")[0]); int width = int.parse(size.split("x")[0]);
int height = int.parse(size.split("x")[1]); int height = int.parse(size.split("x")[1]);
favicons.add(Favicon( favicons.add(Favicon(
url: Uri.tryParse(urlIcon) ?? Uri(), url: WebUri(urlIcon), rel: rel, width: width, height: height));
rel: rel,
width: width,
height: height));
} }
} else { } else {
favicons.add(Favicon( favicons.add(
url: Uri.tryParse(urlIcon) ?? Uri(), Favicon(url: WebUri(urlIcon), rel: rel, width: null, height: null));
rel: rel,
width: null,
height: null));
} }
return favicons; return favicons;
@ -1613,7 +1608,7 @@ class InAppWebViewController {
{required URLRequest urlRequest, {required URLRequest urlRequest,
@Deprecated('Use allowingReadAccessTo instead') @Deprecated('Use allowingReadAccessTo instead')
Uri? iosAllowingReadAccessTo, Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async { WebUri? allowingReadAccessTo}) async {
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
assert( assert(
allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file")); allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
@ -1635,7 +1630,7 @@ class InAppWebViewController {
///Example: ///Example:
///```dart ///```dart
///var postData = Uint8List.fromList(utf8.encode("firstname=Foo&surname=Bar")); ///var postData = Uint8List.fromList(utf8.encode("firstname=Foo&surname=Bar"));
///controller.postUrl(url: Uri.parse("https://www.example.com/"), postData: postData); ///controller.postUrl(url: WebUri("https://www.example.com/"), postData: postData);
///``` ///```
/// ///
///**NOTE for Web**: it will try to create an XMLHttpRequest and load the result inside the iframe. ///**NOTE for Web**: it will try to create an XMLHttpRequest and load the result inside the iframe.
@ -1645,7 +1640,8 @@ class InAppWebViewController {
///- iOS ///- iOS
///- MacOS ///- MacOS
///- Web ///- Web
Future<void> postUrl({required Uri url, required Uint8List postData}) async { Future<void> postUrl(
{required WebUri url, required Uint8List postData}) async {
assert(url.toString().isNotEmpty); assert(url.toString().isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
@ -1676,13 +1672,13 @@ class InAppWebViewController {
{required String data, {required String data,
String mimeType = "text/html", String mimeType = "text/html",
String encoding = "utf8", String encoding = "utf8",
Uri? baseUrl, WebUri? baseUrl,
@Deprecated('Use historyUrl instead') @Deprecated('Use historyUrl instead')
Uri? androidHistoryUrl, Uri? androidHistoryUrl,
Uri? historyUrl, WebUri? historyUrl,
@Deprecated('Use allowingReadAccessTo instead') @Deprecated('Use allowingReadAccessTo instead')
Uri? iosAllowingReadAccessTo, Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async { WebUri? allowingReadAccessTo}) async {
assert( assert(
allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file")); allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
assert(iosAllowingReadAccessTo == null || assert(iosAllowingReadAccessTo == null ||
@ -1938,7 +1934,7 @@ class InAppWebViewController {
///- MacOS ///- MacOS
///- Web ///- Web
Future<void> injectJavascriptFileFromUrl( Future<void> injectJavascriptFileFromUrl(
{required Uri urlFile, {required WebUri urlFile,
ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) async { ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) async {
assert(urlFile.toString().isNotEmpty); assert(urlFile.toString().isNotEmpty);
var id = scriptHtmlTagAttributes?.id; var id = scriptHtmlTagAttributes?.id;
@ -2009,7 +2005,7 @@ class InAppWebViewController {
///- MacOS ///- MacOS
///- Web ///- Web
Future<void> injectCSSFileFromUrl( Future<void> injectCSSFileFromUrl(
{required Uri urlFile, {required WebUri urlFile,
CSSLinkHtmlTagAttributes? cssLinkHtmlTagAttributes}) async { CSSLinkHtmlTagAttributes? cssLinkHtmlTagAttributes}) async {
assert(urlFile.toString().isNotEmpty); assert(urlFile.toString().isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -2453,10 +2449,10 @@ class InAppWebViewController {
///- iOS ///- iOS
///- MacOS ///- MacOS
///- Web ///- Web
Future<Uri?> getOriginalUrl() async { Future<WebUri?> getOriginalUrl() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
String? url = await _channel.invokeMethod('getOriginalUrl', args); String? url = await _channel.invokeMethod('getOriginalUrl', args);
return url != null ? Uri.tryParse(url) : null; return url != null ? WebUri(url) : null;
} }
///Gets the current zoom scale of the WebView. ///Gets the current zoom scale of the WebView.
@ -2553,7 +2549,7 @@ class InAppWebViewController {
await _channel.invokeMethod('requestFocusNodeHref', args); await _channel.invokeMethod('requestFocusNodeHref', args);
return result != null return result != null
? RequestFocusNodeHrefResult( ? RequestFocusNodeHrefResult(
url: result['url'] != null ? Uri.tryParse(result['url']) : null, url: result['url'] != null ? WebUri(result['url']) : null,
title: result['title'], title: result['title'],
src: result['src'], src: result['src'],
) )
@ -2573,7 +2569,7 @@ class InAppWebViewController {
await _channel.invokeMethod('requestImageRef', args); await _channel.invokeMethod('requestImageRef', args);
return result != null return result != null
? RequestImageRefResult( ? RequestImageRefResult(
url: result['url'] != null ? Uri.tryParse(result['url']) : null, url: result['url'] != null ? WebUri(result['url']) : null,
) )
: null; : null;
} }
@ -3018,9 +3014,9 @@ class InAppWebViewController {
///- iOS ///- iOS
///- MacOS ///- MacOS
Future<void> postWebMessage( Future<void> postWebMessage(
{required WebMessage message, Uri? targetOrigin}) async { {required WebMessage message, WebUri? targetOrigin}) async {
if (targetOrigin == null) { if (targetOrigin == null) {
targetOrigin = Uri(); targetOrigin = WebUri('');
} }
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('message', () => message.toMap()); args.putIfAbsent('message', () => message.toMap());
@ -3177,7 +3173,7 @@ class InAppWebViewController {
/// }, /// },
/// )); /// ));
/// } /// }
/// await controller.loadUrl(urlRequest: URLRequest(url: Uri.parse("https://www.example.com"))); /// await controller.loadUrl(urlRequest: URLRequest(url: WebUri("https://www.example.com")));
/// }, /// },
/// ), /// ),
///``` ///```
@ -3541,7 +3537,7 @@ class InAppWebViewController {
///Example: ///Example:
///```dart ///```dart
///controller.loadSimulateloadSimulatedRequestdRequest(urlRequest: URLRequest( ///controller.loadSimulateloadSimulatedRequestdRequest(urlRequest: URLRequest(
/// url: Uri.parse("https://flutter.dev"), /// url: WebUri("https://flutter.dev"),
/// ), /// ),
/// data: Uint8List.fromList(utf8.encode("<h1>Hello</h1>")) /// data: Uint8List.fromList(utf8.encode("<h1>Hello</h1>"))
///); ///);
@ -3606,11 +3602,11 @@ class InAppWebViewController {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewCompat.getSafeBrowsingPrivacyPolicyUrl](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl())) ///- Android native WebView ([Official API - WebViewCompat.getSafeBrowsingPrivacyPolicyUrl](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl()))
static Future<Uri?> getSafeBrowsingPrivacyPolicyUrl() async { static Future<WebUri?> getSafeBrowsingPrivacyPolicyUrl() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
String? url = await _staticChannel.invokeMethod( String? url = await _staticChannel.invokeMethod(
'getSafeBrowsingPrivacyPolicyUrl', args); 'getSafeBrowsingPrivacyPolicyUrl', args);
return url != null ? Uri.tryParse(url) : null; return url != null ? WebUri(url) : null;
} }
///Use [setSafeBrowsingAllowlist] instead. ///Use [setSafeBrowsingAllowlist] instead.

View File

@ -21,6 +21,7 @@ import '../types/scrollview_content_inset_adjustment_behavior.dart';
import '../types/scrollview_deceleration_rate.dart'; import '../types/scrollview_deceleration_rate.dart';
import '../types/selection_granularity.dart'; import '../types/selection_granularity.dart';
import '../types/vertical_scrollbar_position.dart'; import '../types/vertical_scrollbar_position.dart';
import '../web_uri.dart';
import 'android/in_app_webview_options.dart'; import 'android/in_app_webview_options.dart';
import 'apple/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart';
import '../content_blocker.dart'; import '../content_blocker.dart';
@ -1123,7 +1124,7 @@ class InAppWebViewSettings_ {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ///- iOS
///- MacOS ///- MacOS
Uri? allowingReadAccessTo; WebUri? allowingReadAccessTo;
///Set to `true` to disable the context menu (copy, select, etc.) that is shown when the user emits a long press event on a HTML link. ///Set to `true` to disable the context menu (copy, select, etc.) that is shown when the user emits a long press event on a HTML link.
///This is implemented using also JavaScript, so it must be enabled or it won't work. ///This is implemented using also JavaScript, so it must be enabled or it won't work.

View File

@ -1080,7 +1080,7 @@ class InAppWebViewSettings {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ///- iOS
///- MacOS ///- MacOS
Uri? allowingReadAccessTo; WebUri? allowingReadAccessTo;
///Set to `true` to disable the context menu (copy, select, etc.) that is shown when the user emits a long press event on a HTML link. ///Set to `true` to disable the context menu (copy, select, etc.) that is shown when the user emits a long press event on a HTML link.
///This is implemented using also JavaScript, so it must be enabled or it won't work. ///This is implemented using also JavaScript, so it must be enabled or it won't work.
@ -1430,7 +1430,7 @@ class InAppWebViewSettings {
map['requestedWithHeaderMode']), map['requestedWithHeaderMode']),
mediaType: map['mediaType'], mediaType: map['mediaType'],
allowingReadAccessTo: map['allowingReadAccessTo'] != null allowingReadAccessTo: map['allowingReadAccessTo'] != null
? Uri.tryParse(map['allowingReadAccessTo']) ? WebUri(map['allowingReadAccessTo'])
: null, : null,
underPageBackgroundColor: map['underPageBackgroundColor'] != null underPageBackgroundColor: map['underPageBackgroundColor'] != null
? UtilColor.fromStringRepresentation(map['underPageBackgroundColor']) ? UtilColor.fromStringRepresentation(map['underPageBackgroundColor'])

View File

@ -7,6 +7,7 @@ import '../pull_to_refresh/pull_to_refresh_controller.dart';
import '../context_menu.dart'; import '../context_menu.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../web_uri.dart';
import 'in_app_webview_controller.dart'; import 'in_app_webview_controller.dart';
import 'in_app_webview_settings.dart'; import 'in_app_webview_settings.dart';
import 'headless_in_app_webview.dart'; import 'headless_in_app_webview.dart';
@ -52,7 +53,8 @@ abstract class WebView {
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- Web ///- Web
final void Function(InAppWebViewController controller, Uri? url)? onLoadStart; final void Function(InAppWebViewController controller, WebUri? url)?
onLoadStart;
///Event fired when the [WebView] finishes loading an [url]. ///Event fired when the [WebView] finishes loading an [url].
/// ///
@ -64,7 +66,8 @@ abstract class WebView {
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)) ///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event))
final void Function(InAppWebViewController controller, Uri? url)? onLoadStop; final void Function(InAppWebViewController controller, WebUri? url)?
onLoadStop;
///Use [onReceivedError] instead. ///Use [onReceivedError] instead.
@Deprecated("Use onReceivedError instead") @Deprecated("Use onReceivedError instead")
@ -459,7 +462,7 @@ abstract class WebView {
///- MacOS ///- MacOS
///- Web ///- Web
final void Function( final void Function(
InAppWebViewController controller, Uri? url, bool? isReload)? InAppWebViewController controller, WebUri? url, bool? isReload)?
onUpdateVisitedHistory; onUpdateVisitedHistory;
///Use [onPrintRequest] instead ///Use [onPrintRequest] instead
@ -482,7 +485,7 @@ abstract class WebView {
///- iOS ///- iOS
///- MacOS ///- MacOS
///- Web ///- Web
final Future<bool?> Function(InAppWebViewController controller, Uri? url, final Future<bool?> Function(InAppWebViewController controller, WebUri? url,
PrintJobController? printJobController)? onPrintRequest; PrintJobController? printJobController)? onPrintRequest;
///Event fired when an HTML element of the webview has been clicked and held. ///Event fired when an HTML element of the webview has been clicked and held.
@ -528,7 +531,7 @@ abstract class WebView {
///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String))) ///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
final void Function(InAppWebViewController controller, Uri? url)? final void Function(InAppWebViewController controller, WebUri? url)?
onPageCommitVisible; onPageCommitVisible;
///Event fired when a change in the document title occurred. ///Event fired when a change in the document title occurred.
@ -597,7 +600,7 @@ abstract class WebView {
///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)))
final Future<SafeBrowsingResponse?> Function( final Future<SafeBrowsingResponse?> Function(
InAppWebViewController controller, InAppWebViewController controller,
Uri url, WebUri url,
SafeBrowsingThreat? threatType)? onSafeBrowsingHit; SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
///Use [onPermissionRequest] instead. ///Use [onPermissionRequest] instead.
@ -709,7 +712,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessUnresponsive;
///Use [onRenderProcessResponsive] instead. ///Use [onRenderProcessResponsive] instead.
@Deprecated("Use onRenderProcessResponsive instead") @Deprecated("Use onRenderProcessResponsive instead")
@ -730,7 +734,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive; InAppWebViewController controller, WebUri? url)?
onRenderProcessResponsive;
///Use [onRenderProcessGone] instead. ///Use [onRenderProcessGone] instead.
@Deprecated("Use onRenderProcessGone instead") @Deprecated("Use onRenderProcessGone instead")
@ -762,7 +767,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)))
final Future<FormResubmissionAction?> Function( final Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission; InAppWebViewController controller, WebUri? url)? onFormResubmission;
///Use [onZoomScaleChanged] instead. ///Use [onZoomScaleChanged] instead.
@Deprecated('Use onZoomScaleChanged instead') @Deprecated('Use onZoomScaleChanged instead')
@ -799,7 +804,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)))
final void Function( final void Function(
InAppWebViewController controller, Uri url, bool precomposed)? InAppWebViewController controller, WebUri url, bool precomposed)?
onReceivedTouchIconUrl; onReceivedTouchIconUrl;
///Use [onJsBeforeUnload] instead. ///Use [onJsBeforeUnload] instead.

View File

@ -18,3 +18,4 @@ export 'web_authentication_session/main.dart';
export 'print_job/main.dart'; export 'print_job/main.dart';
export 'debug_logging_settings.dart'; export 'debug_logging_settings.dart';
export 'find_interaction/main.dart'; export 'find_interaction/main.dart';
export 'web_uri.dart';

View File

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../util.dart'; import '../util.dart';
import '../web_uri.dart';
import 'print_job_controller.dart'; import 'print_job_controller.dart';
///Class that represents the settings of a [PrintJobController]. ///Class that represents the settings of a [PrintJobController].
@ -244,7 +245,7 @@ class PrintJobSettings {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- MacOS ///- MacOS
Uri? jobSavingURL; WebUri? jobSavingURL;
///The name of the currently selected paper size. ///The name of the currently selected paper size.
/// ///
@ -440,9 +441,8 @@ class PrintJobSettings {
showsProgressPanel: map["showsProgressPanel"], showsProgressPanel: map["showsProgressPanel"],
jobDisposition: jobDisposition:
PrintJobDisposition.fromNativeValue(map["jobDisposition"]), PrintJobDisposition.fromNativeValue(map["jobDisposition"]),
jobSavingURL: map["jobSavingURL"] != null jobSavingURL:
? Uri.tryParse(map["jobSavingURL"]) map["jobSavingURL"] != null ? WebUri(map["jobSavingURL"]) : null,
: null,
paperName: map["paperName"], paperName: map["paperName"],
horizontalPagination: horizontalPagination:
PrintJobPaginationMode.fromNativeValue(map["horizontalPagination"]), PrintJobPaginationMode.fromNativeValue(map["horizontalPagination"]),

View File

@ -1,5 +1,6 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
import 'ajax_request_headers.dart'; import 'ajax_request_headers.dart';
import 'ajax_request_ready_state.dart'; import 'ajax_request_ready_state.dart';
import 'ajax_request_event.dart'; import 'ajax_request_event.dart';
@ -17,7 +18,7 @@ class AjaxRequest_ {
String? method; String? method;
///The URL of the `XMLHttpRequest` request. ///The URL of the `XMLHttpRequest` request.
Uri? url; WebUri? url;
///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously. ///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously.
bool? isAsync; bool? isAsync;
@ -46,7 +47,7 @@ class AjaxRequest_ {
///The serialized URL of the response or the empty string if the URL is null. ///The serialized URL of the response or the empty string if the URL is null.
///If the URL is returned, any URL fragment present in the URL will be stripped away. ///If the URL is returned, any URL fragment present in the URL will be stripped away.
///The value of responseURL will be the final URL obtained after any redirects. ///The value of responseURL will be the final URL obtained after any redirects.
Uri? responseURL; WebUri? responseURL;
///It is an enumerated string value specifying the type of data contained in the response. ///It is an enumerated string value specifying the type of data contained in the response.
///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType). ///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).

View File

@ -15,7 +15,7 @@ class AjaxRequest {
String? method; String? method;
///The URL of the `XMLHttpRequest` request. ///The URL of the `XMLHttpRequest` request.
Uri? url; WebUri? url;
///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously. ///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously.
bool? isAsync; bool? isAsync;
@ -44,7 +44,7 @@ class AjaxRequest {
///The serialized URL of the response or the empty string if the URL is null. ///The serialized URL of the response or the empty string if the URL is null.
///If the URL is returned, any URL fragment present in the URL will be stripped away. ///If the URL is returned, any URL fragment present in the URL will be stripped away.
///The value of responseURL will be the final URL obtained after any redirects. ///The value of responseURL will be the final URL obtained after any redirects.
Uri? responseURL; WebUri? responseURL;
///It is an enumerated string value specifying the type of data contained in the response. ///It is an enumerated string value specifying the type of data contained in the response.
///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType). ///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).
@ -103,7 +103,7 @@ class AjaxRequest {
final instance = AjaxRequest( final instance = AjaxRequest(
data: map['data'], data: map['data'],
method: map['method'], method: map['method'],
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
isAsync: map['isAsync'], isAsync: map['isAsync'],
user: map['user'], user: map['user'],
password: map['password'], password: map['password'],
@ -113,7 +113,7 @@ class AjaxRequest {
readyState: AjaxRequestReadyState.fromNativeValue(map['readyState']), readyState: AjaxRequestReadyState.fromNativeValue(map['readyState']),
status: map['status'], status: map['status'],
responseURL: responseURL:
map['responseURL'] != null ? Uri.tryParse(map['responseURL']) : null, map['responseURL'] != null ? WebUri(map['responseURL']) : null,
responseType: map['responseType'], responseType: map['responseType'],
response: map['response'], response: map['response'],
responseText: map['responseText'], responseText: map['responseText'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'download_start_request.g.dart'; part 'download_start_request.g.dart';
@ -8,7 +9,7 @@ part 'download_start_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class DownloadStartRequest_ { class DownloadStartRequest_ {
///The full url to the content that should be downloaded. ///The full url to the content that should be downloaded.
Uri url; WebUri url;
///the user agent to be used for the download. ///the user agent to be used for the download.
String? userAgent; String? userAgent;

View File

@ -9,7 +9,7 @@ part of 'download_start_request.dart';
///Class representing a download request of the WebView used by the event [WebView.onDownloadStartRequest]. ///Class representing a download request of the WebView used by the event [WebView.onDownloadStartRequest].
class DownloadStartRequest { class DownloadStartRequest {
///The full url to the content that should be downloaded. ///The full url to the content that should be downloaded.
Uri url; WebUri url;
///the user agent to be used for the download. ///the user agent to be used for the download.
String? userAgent; String? userAgent;
@ -43,7 +43,7 @@ class DownloadStartRequest {
return null; return null;
} }
final instance = DownloadStartRequest( final instance = DownloadStartRequest(
url: (Uri.tryParse(map['url']) ?? Uri()), url: WebUri(map['url']),
userAgent: map['userAgent'], userAgent: map['userAgent'],
contentDisposition: map['contentDisposition'], contentDisposition: map['contentDisposition'],
mimeType: map['mimeType'], mimeType: map['mimeType'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/in_app_webview_controller.dart'; import '../in_app_webview/in_app_webview_controller.dart';
import '../web_uri.dart';
part 'favicon.g.dart'; part 'favicon.g.dart';
@ -8,7 +9,7 @@ part 'favicon.g.dart';
@ExchangeableObject() @ExchangeableObject()
class Favicon_ { class Favicon_ {
///The url of the favicon image. ///The url of the favicon image.
Uri url; WebUri url;
///The relationship between the current web page and the favicon image. ///The relationship between the current web page and the favicon image.
String? rel; String? rel;

View File

@ -9,7 +9,7 @@ part of 'favicon.dart';
///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method. ///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method.
class Favicon { class Favicon {
///The url of the favicon image. ///The url of the favicon image.
Uri url; WebUri url;
///The relationship between the current web page and the favicon image. ///The relationship between the current web page and the favicon image.
String? rel; String? rel;
@ -27,7 +27,7 @@ class Favicon {
return null; return null;
} }
final instance = Favicon( final instance = Favicon(
url: (Uri.tryParse(map['url']) ?? Uri()), url: WebUri(map['url']),
rel: map['rel'], rel: map['rel'],
width: map['width'], width: map['width'],
height: map['height'], height: map['height'],

View File

@ -1,5 +1,6 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
import 'fetch_request_action.dart'; import 'fetch_request_action.dart';
import 'fetch_request_credential.dart'; import 'fetch_request_credential.dart';
import 'fetch_request_credential_default.dart'; import 'fetch_request_credential_default.dart';
@ -28,7 +29,7 @@ FetchRequestCredential? _fetchRequestCredentialDeserializer(dynamic value) {
@ExchangeableObject() @ExchangeableObject()
class FetchRequest_ { class FetchRequest_ {
///The URL of the request. ///The URL of the request.
Uri? url; WebUri? url;
///The HTTP request method used of the request. ///The HTTP request method used of the request.
String? method; String? method;

View File

@ -9,7 +9,7 @@ part of 'fetch_request.dart';
///Class that represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). ///Class that represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).
class FetchRequest { class FetchRequest {
///The URL of the request. ///The URL of the request.
Uri? url; WebUri? url;
///The HTTP request method used of the request. ///The HTTP request method used of the request.
String? method; String? method;
@ -67,7 +67,7 @@ class FetchRequest {
return null; return null;
} }
final instance = FetchRequest( final instance = FetchRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
method: map['method'], method: map['method'],
headers: map['headers']?.cast<String, dynamic>(), headers: map['headers']?.cast<String, dynamic>(),
body: map['body'], body: map['body'],

View File

@ -1,5 +1,6 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
import 'fetch_request_credential.dart'; import 'fetch_request_credential.dart';
part 'fetch_request_federated_credential.g.dart'; part 'fetch_request_federated_credential.g.dart';
@ -20,7 +21,7 @@ class FetchRequestFederatedCredential_ extends FetchRequestCredential_ {
String? provider; String? provider;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
Uri? iconURL; WebUri? iconURL;
FetchRequestFederatedCredential_( FetchRequestFederatedCredential_(
{type, this.id, this.name, this.protocol, this.provider, this.iconURL}) {type, this.id, this.name, this.protocol, this.provider, this.iconURL})

View File

@ -21,7 +21,7 @@ class FetchRequestFederatedCredential extends FetchRequestCredential {
String? provider; String? provider;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
Uri? iconURL; WebUri? iconURL;
FetchRequestFederatedCredential( FetchRequestFederatedCredential(
{this.id, {this.id,
this.name, this.name,
@ -41,7 +41,7 @@ class FetchRequestFederatedCredential extends FetchRequestCredential {
name: map['name'], name: map['name'],
protocol: map['protocol'], protocol: map['protocol'],
provider: map['provider'], provider: map['provider'],
iconURL: map['iconURL'] != null ? Uri.tryParse(map['iconURL']) : null, iconURL: map['iconURL'] != null ? WebUri(map['iconURL']) : null,
); );
instance.type = map['type']; instance.type = map['type'];
return instance; return instance;

View File

@ -1,5 +1,6 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
import 'fetch_request_credential.dart'; import 'fetch_request_credential.dart';
part 'fetch_request_password_credential.g.dart'; part 'fetch_request_password_credential.g.dart';
@ -17,7 +18,7 @@ class FetchRequestPasswordCredential_ extends FetchRequestCredential_ {
String? password; String? password;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
Uri? iconURL; WebUri? iconURL;
FetchRequestPasswordCredential_( FetchRequestPasswordCredential_(
{type, this.id, this.name, this.password, this.iconURL}) {type, this.id, this.name, this.password, this.iconURL})

View File

@ -18,7 +18,7 @@ class FetchRequestPasswordCredential extends FetchRequestCredential {
String? password; String? password;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
Uri? iconURL; WebUri? iconURL;
FetchRequestPasswordCredential( FetchRequestPasswordCredential(
{this.id, this.name, this.password, this.iconURL, String? type}) {this.id, this.name, this.password, this.iconURL, String? type})
: super(type: type); : super(type: type);
@ -32,7 +32,7 @@ class FetchRequestPasswordCredential extends FetchRequestCredential {
id: map['id'], id: map['id'],
name: map['name'], name: map['name'],
password: map['password'], password: map['password'],
iconURL: map['iconURL'] != null ? Uri.tryParse(map['iconURL']) : null, iconURL: map['iconURL'] != null ? WebUri(map['iconURL']) : null,
); );
instance.type = map['type']; instance.type = map['type'];
return instance; return instance;

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'in_app_webview_initial_data.g.dart'; part 'in_app_webview_initial_data.g.dart';
@ -17,7 +18,7 @@ class InAppWebViewInitialData_ {
String encoding; String encoding;
///The URL to use as the page's base URL. If `null` defaults to `about:blank`. ///The URL to use as the page's base URL. If `null` defaults to `about:blank`.
Uri? baseUrl; WebUri? baseUrl;
///Use [historyUrl] instead. ///Use [historyUrl] instead.
@Deprecated('Use historyUrl instead') @Deprecated('Use historyUrl instead')
@ -25,7 +26,7 @@ class InAppWebViewInitialData_ {
///The URL to use as the history entry. If `null` defaults to `about:blank`. If non-null, this must be a valid URL. ///The URL to use as the history entry. If `null` defaults to `about:blank`. If non-null, this must be a valid URL.
@SupportedPlatforms(platforms: [AndroidPlatform()]) @SupportedPlatforms(platforms: [AndroidPlatform()])
Uri? historyUrl; WebUri? historyUrl;
InAppWebViewInitialData_( InAppWebViewInitialData_(
{required this.data, {required this.data,

View File

@ -18,7 +18,7 @@ class InAppWebViewInitialData {
String encoding; String encoding;
///The URL to use as the page's base URL. If `null` defaults to `about:blank`. ///The URL to use as the page's base URL. If `null` defaults to `about:blank`.
Uri? baseUrl; WebUri? baseUrl;
///Use [historyUrl] instead. ///Use [historyUrl] instead.
@Deprecated('Use historyUrl instead') @Deprecated('Use historyUrl instead')
@ -28,7 +28,7 @@ class InAppWebViewInitialData {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ///- Android native WebView
Uri? historyUrl; WebUri? historyUrl;
InAppWebViewInitialData( InAppWebViewInitialData(
{required this.data, {required this.data,
this.mimeType = "text/html", this.mimeType = "text/html",
@ -36,7 +36,8 @@ class InAppWebViewInitialData {
this.baseUrl, this.baseUrl,
@Deprecated('Use historyUrl instead') this.androidHistoryUrl, @Deprecated('Use historyUrl instead') this.androidHistoryUrl,
this.historyUrl}) { this.historyUrl}) {
historyUrl = historyUrl ?? androidHistoryUrl; historyUrl = historyUrl ??
(androidHistoryUrl != null ? WebUri.uri(androidHistoryUrl!) : null);
} }
///Gets a possible [InAppWebViewInitialData] instance from a [Map] value. ///Gets a possible [InAppWebViewInitialData] instance from a [Map] value.
@ -46,11 +47,10 @@ class InAppWebViewInitialData {
} }
final instance = InAppWebViewInitialData( final instance = InAppWebViewInitialData(
data: map['data'], data: map['data'],
baseUrl: map['baseUrl'] != null ? Uri.tryParse(map['baseUrl']) : null, baseUrl: map['baseUrl'] != null ? WebUri(map['baseUrl']) : null,
androidHistoryUrl: androidHistoryUrl:
map['historyUrl'] != null ? Uri.tryParse(map['historyUrl']) : null, map['historyUrl'] != null ? Uri.tryParse(map['historyUrl']) : null,
historyUrl: historyUrl: map['historyUrl'] != null ? WebUri(map['historyUrl']) : null,
map['historyUrl'] != null ? Uri.tryParse(map['historyUrl']) : null,
); );
instance.mimeType = map['mimeType']; instance.mimeType = map['mimeType'];
instance.encoding = map['encoding']; instance.encoding = map['encoding'];

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'js_alert_request.g.dart'; part 'js_alert_request.g.dart';
@ -8,7 +9,7 @@ part 'js_alert_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class JsAlertRequest_ { class JsAlertRequest_ {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;

View File

@ -9,7 +9,7 @@ part of 'js_alert_request.dart';
///Class that represents the request of the [WebView.onJsAlert] event. ///Class that represents the request of the [WebView.onJsAlert] event.
class JsAlertRequest { class JsAlertRequest {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;
@ -37,7 +37,7 @@ class JsAlertRequest {
return null; return null;
} }
final instance = JsAlertRequest( final instance = JsAlertRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
message: map['message'], message: map['message'],
iosIsMainFrame: map['isMainFrame'], iosIsMainFrame: map['isMainFrame'],
isMainFrame: map['isMainFrame'], isMainFrame: map['isMainFrame'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'js_before_unload_request.g.dart'; part 'js_before_unload_request.g.dart';
@ -8,7 +9,7 @@ part 'js_before_unload_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class JsBeforeUnloadRequest_ { class JsBeforeUnloadRequest_ {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;

View File

@ -9,7 +9,7 @@ part of 'js_before_unload_request.dart';
///Class that represents the request of the [WebView.onJsBeforeUnload] event. ///Class that represents the request of the [WebView.onJsBeforeUnload] event.
class JsBeforeUnloadRequest { class JsBeforeUnloadRequest {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;
@ -21,7 +21,7 @@ class JsBeforeUnloadRequest {
return null; return null;
} }
final instance = JsBeforeUnloadRequest( final instance = JsBeforeUnloadRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
message: map['message'], message: map['message'],
); );
return instance; return instance;

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'js_confirm_request.g.dart'; part 'js_confirm_request.g.dart';
@ -8,7 +9,7 @@ part 'js_confirm_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class JsConfirmRequest_ { class JsConfirmRequest_ {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;

View File

@ -9,7 +9,7 @@ part of 'js_confirm_request.dart';
///Class that represents the request of the [WebView.onJsConfirm] event. ///Class that represents the request of the [WebView.onJsConfirm] event.
class JsConfirmRequest { class JsConfirmRequest {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;
@ -37,7 +37,7 @@ class JsConfirmRequest {
return null; return null;
} }
final instance = JsConfirmRequest( final instance = JsConfirmRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
message: map['message'], message: map['message'],
iosIsMainFrame: map['isMainFrame'], iosIsMainFrame: map['isMainFrame'],
isMainFrame: map['isMainFrame'], isMainFrame: map['isMainFrame'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'js_prompt_request.g.dart'; part 'js_prompt_request.g.dart';
@ -8,7 +9,7 @@ part 'js_prompt_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class JsPromptRequest_ { class JsPromptRequest_ {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;

View File

@ -9,7 +9,7 @@ part of 'js_prompt_request.dart';
///Class that represents the request of the [WebView.onJsPrompt] event. ///Class that represents the request of the [WebView.onJsPrompt] event.
class JsPromptRequest { class JsPromptRequest {
///The url of the page requesting the dialog. ///The url of the page requesting the dialog.
Uri? url; WebUri? url;
///Message to be displayed in the window. ///Message to be displayed in the window.
String? message; String? message;
@ -41,7 +41,7 @@ class JsPromptRequest {
return null; return null;
} }
final instance = JsPromptRequest( final instance = JsPromptRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
message: map['message'], message: map['message'],
defaultValue: map['defaultValue'], defaultValue: map['defaultValue'],
iosIsMainFrame: map['isMainFrame'], iosIsMainFrame: map['isMainFrame'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'loaded_resource.g.dart'; part 'loaded_resource.g.dart';
@ -12,7 +13,7 @@ class LoadedResource_ {
String? initiatorType; String? initiatorType;
///Resource URL. ///Resource URL.
Uri? url; WebUri? url;
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started. ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started.
double? startTime; double? startTime;

View File

@ -13,7 +13,7 @@ class LoadedResource {
String? initiatorType; String? initiatorType;
///Resource URL. ///Resource URL.
Uri? url; WebUri? url;
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started. ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started.
double? startTime; double? startTime;
@ -29,7 +29,7 @@ class LoadedResource {
} }
final instance = LoadedResource( final instance = LoadedResource(
initiatorType: map['initiatorType'], initiatorType: map['initiatorType'],
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
startTime: map['startTime'], startTime: map['startTime'],
duration: map['duration'], duration: map['duration'],
); );

View File

@ -1,5 +1,6 @@
import '../web_message/main.dart'; import '../web_message/main.dart';
import '../web_uri.dart';
///The listener for handling [WebMessageListener] events sent by a `postMessage()` on the injected JavaScript object. ///The listener for handling [WebMessageListener] events sent by a `postMessage()` on the injected JavaScript object.
typedef void OnPostMessageCallback(String? message, Uri? sourceOrigin, typedef void OnPostMessageCallback(String? message, WebUri? sourceOrigin,
bool isMainFrame, JavaScriptReplyProxy replyProxy); bool isMainFrame, JavaScriptReplyProxy replyProxy);

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
import 'permission_resource_type.dart'; import 'permission_resource_type.dart';
import 'permission_response.dart'; import 'permission_response.dart';
import 'frame_info.dart'; import 'frame_info.dart';
@ -11,7 +12,7 @@ part 'permission_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class PermissionRequest_ { class PermissionRequest_ {
///The origin of web content which attempt to access the restricted resources. ///The origin of web content which attempt to access the restricted resources.
Uri origin; WebUri origin;
///List of resources the web content wants to access. ///List of resources the web content wants to access.
/// ///

View File

@ -9,7 +9,7 @@ part of 'permission_request.dart';
///Class that represents the response used by the [WebView.onPermissionRequest] event. ///Class that represents the response used by the [WebView.onPermissionRequest] event.
class PermissionRequest { class PermissionRequest {
///The origin of web content which attempt to access the restricted resources. ///The origin of web content which attempt to access the restricted resources.
Uri origin; WebUri origin;
///List of resources the web content wants to access. ///List of resources the web content wants to access.
/// ///
@ -28,7 +28,7 @@ class PermissionRequest {
return null; return null;
} }
final instance = PermissionRequest( final instance = PermissionRequest(
origin: (Uri.tryParse(map['origin']) ?? Uri()), origin: WebUri(map['origin']),
frame: FrameInfo.fromMap(map['frame']?.cast<String, dynamic>()), frame: FrameInfo.fromMap(map['frame']?.cast<String, dynamic>()),
); );
instance.resources = List<PermissionResourceType>.from(map['resources'] instance.resources = List<PermissionResourceType>.from(map['resources']

View File

@ -3,6 +3,7 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i
import '../util.dart'; import '../util.dart';
import '../print_job/main.dart'; import '../print_job/main.dart';
import '../web_uri.dart';
import 'in_app_webview_rect.dart'; import 'in_app_webview_rect.dart';
import 'print_job_color_mode.dart'; import 'print_job_color_mode.dart';
import 'print_job_duplex_mode.dart'; import 'print_job_duplex_mode.dart';
@ -130,7 +131,7 @@ class PrintJobAttributes_ {
///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE].
@SupportedPlatforms(platforms: [MacOSPlatform()]) @SupportedPlatforms(platforms: [MacOSPlatform()])
Uri? jobSavingURL; WebUri? jobSavingURL;
///If `true`, produce detailed reports when an error occurs. ///If `true`, produce detailed reports when an error occurs.
@SupportedPlatforms(platforms: [MacOSPlatform()]) @SupportedPlatforms(platforms: [MacOSPlatform()])

View File

@ -165,7 +165,7 @@ class PrintJobAttributes {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- MacOS ///- MacOS
Uri? jobSavingURL; WebUri? jobSavingURL;
///If `true`, produce detailed reports when an error occurs. ///If `true`, produce detailed reports when an error occurs.
/// ///
@ -273,9 +273,8 @@ class PrintJobAttributes {
isVerticallyCentered: map['isVerticallyCentered'], isVerticallyCentered: map['isVerticallyCentered'],
isSelectionOnly: map['isSelectionOnly'], isSelectionOnly: map['isSelectionOnly'],
scalingFactor: map['scalingFactor'], scalingFactor: map['scalingFactor'],
jobSavingURL: map['jobSavingURL'] != null jobSavingURL:
? Uri.tryParse(map['jobSavingURL']) map['jobSavingURL'] != null ? WebUri(map['jobSavingURL']) : null,
: null,
detailedErrorReporting: map['detailedErrorReporting'], detailedErrorReporting: map['detailedErrorReporting'],
faxNumber: map['faxNumber'], faxNumber: map['faxNumber'],
headerAndFooter: map['headerAndFooter'], headerAndFooter: map['headerAndFooter'],

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/in_app_webview_controller.dart'; import '../in_app_webview/in_app_webview_controller.dart';
import '../web_uri.dart';
part 'request_focus_node_href_result.g.dart'; part 'request_focus_node_href_result.g.dart';
@ -8,7 +9,7 @@ part 'request_focus_node_href_result.g.dart';
@ExchangeableObject() @ExchangeableObject()
class RequestFocusNodeHrefResult_ { class RequestFocusNodeHrefResult_ {
///The anchor's href attribute. ///The anchor's href attribute.
Uri? url; WebUri? url;
///The anchor's text. ///The anchor's text.
String? title; String? title;

View File

@ -9,7 +9,7 @@ part of 'request_focus_node_href_result.dart';
///Class that represents the result used by the [InAppWebViewController.requestFocusNodeHref] method. ///Class that represents the result used by the [InAppWebViewController.requestFocusNodeHref] method.
class RequestFocusNodeHrefResult { class RequestFocusNodeHrefResult {
///The anchor's href attribute. ///The anchor's href attribute.
Uri? url; WebUri? url;
///The anchor's text. ///The anchor's text.
String? title; String? title;
@ -24,7 +24,7 @@ class RequestFocusNodeHrefResult {
return null; return null;
} }
final instance = RequestFocusNodeHrefResult( final instance = RequestFocusNodeHrefResult(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
title: map['title'], title: map['title'],
src: map['src'], src: map['src'],
); );

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/in_app_webview_controller.dart'; import '../in_app_webview/in_app_webview_controller.dart';
import '../web_uri.dart';
part 'request_image_ref_result.g.dart'; part 'request_image_ref_result.g.dart';
@ -8,7 +9,7 @@ part 'request_image_ref_result.g.dart';
@ExchangeableObject() @ExchangeableObject()
class RequestImageRefResult_ { class RequestImageRefResult_ {
///The image's url. ///The image's url.
Uri? url; WebUri? url;
RequestImageRefResult_({this.url}); RequestImageRefResult_({this.url});
} }

View File

@ -9,7 +9,7 @@ part of 'request_image_ref_result.dart';
///Class that represents the result used by the [InAppWebViewController.requestImageRef] method. ///Class that represents the result used by the [InAppWebViewController.requestImageRef] method.
class RequestImageRefResult { class RequestImageRefResult {
///The image's url. ///The image's url.
Uri? url; WebUri? url;
RequestImageRefResult({this.url}); RequestImageRefResult({this.url});
///Gets a possible [RequestImageRefResult] instance from a [Map] value. ///Gets a possible [RequestImageRefResult] instance from a [Map] value.
@ -18,7 +18,7 @@ class RequestImageRefResult {
return null; return null;
} }
final instance = RequestImageRefResult( final instance = RequestImageRefResult(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
); );
return instance; return instance;
} }

View File

@ -1,5 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
part 'ui_event_attribution.g.dart'; part 'ui_event_attribution.g.dart';
///Class that represents an object that contains event attribution information for Private Click Measurement. ///Class that represents an object that contains event attribution information for Private Click Measurement.
@ -18,7 +20,7 @@ class UIEventAttribution_ {
int sourceIdentifier; int sourceIdentifier;
///The destination URL of the attribution. ///The destination URL of the attribution.
Uri destinationURL; WebUri destinationURL;
///A description of the source of the attribution. ///A description of the source of the attribution.
String sourceDescription; String sourceDescription;

View File

@ -21,7 +21,7 @@ class UIEventAttribution {
int sourceIdentifier; int sourceIdentifier;
///The destination URL of the attribution. ///The destination URL of the attribution.
Uri destinationURL; WebUri destinationURL;
///A description of the source of the attribution. ///A description of the source of the attribution.
String sourceDescription; String sourceDescription;
@ -41,7 +41,7 @@ class UIEventAttribution {
} }
final instance = UIEventAttribution( final instance = UIEventAttribution(
sourceIdentifier: map['sourceIdentifier'], sourceIdentifier: map['sourceIdentifier'],
destinationURL: (Uri.tryParse(map['destinationURL']) ?? Uri()), destinationURL: WebUri(map['destinationURL']),
sourceDescription: map['sourceDescription'], sourceDescription: map['sourceDescription'],
purchaser: map['purchaser'], purchaser: map['purchaser'],
); );

View File

@ -1,6 +1,7 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
import 'url_request_cache_policy.dart'; import 'url_request_cache_policy.dart';
import 'url_request_network_service_type.dart'; import 'url_request_network_service_type.dart';
import 'url_request_attribution.dart'; import 'url_request_attribution.dart';
@ -11,7 +12,7 @@ part 'url_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class URLRequest_ { class URLRequest_ {
///The URL of the request. Setting this to `null` will load `about:blank`. ///The URL of the request. Setting this to `null` will load `about:blank`.
Uri? url; WebUri? url;
///The HTTP request method. ///The HTTP request method.
/// ///
@ -142,7 +143,7 @@ class URLRequest_ {
apiUrl: apiUrl:
"https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl") "https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl")
]) ])
Uri? mainDocumentURL; WebUri? mainDocumentURL;
///`true` if server endpoint is known to support HTTP/3. Enables QUIC racing ///`true` if server endpoint is known to support HTTP/3. Enables QUIC racing
///without HTTP/3 service discovery. Defaults to `false`. ///without HTTP/3 service discovery. Defaults to `false`.

View File

@ -9,7 +9,7 @@ part of 'url_request.dart';
///A URL load request that is independent of protocol or URL scheme. ///A URL load request that is independent of protocol or URL scheme.
class URLRequest { class URLRequest {
///The URL of the request. Setting this to `null` will load `about:blank`. ///The URL of the request. Setting this to `null` will load `about:blank`.
Uri? url; WebUri? url;
///The HTTP request method. ///The HTTP request method.
/// ///
@ -111,7 +111,7 @@ class URLRequest {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl)) ///- iOS ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl))
Uri? mainDocumentURL; WebUri? mainDocumentURL;
///`true` if server endpoint is known to support HTTP/3. Enables QUIC racing ///`true` if server endpoint is known to support HTTP/3. Enables QUIC racing
///without HTTP/3 service discovery. Defaults to `false`. ///without HTTP/3 service discovery. Defaults to `false`.
@ -177,7 +177,8 @@ class URLRequest {
URLRequestNetworkServiceType.fromNativeValue( URLRequestNetworkServiceType.fromNativeValue(
iosNetworkServiceType?.toNativeValue()); iosNetworkServiceType?.toNativeValue());
timeoutInterval = timeoutInterval ?? iosTimeoutInterval; timeoutInterval = timeoutInterval ?? iosTimeoutInterval;
mainDocumentURL = mainDocumentURL ?? iosMainDocumentURL; mainDocumentURL = mainDocumentURL ??
(iosMainDocumentURL != null ? WebUri.uri(iosMainDocumentURL!) : null);
} }
///Gets a possible [URLRequest] instance from a [Map] value. ///Gets a possible [URLRequest] instance from a [Map] value.
@ -186,7 +187,7 @@ class URLRequest {
return null; return null;
} }
final instance = URLRequest( final instance = URLRequest(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
method: map['method'], method: map['method'],
body: map['body'], body: map['body'],
headers: map['headers']?.cast<String, String>(), headers: map['headers']?.cast<String, String>(),
@ -213,7 +214,7 @@ class URLRequest {
? Uri.tryParse(map['mainDocumentURL']) ? Uri.tryParse(map['mainDocumentURL'])
: null, : null,
mainDocumentURL: map['mainDocumentURL'] != null mainDocumentURL: map['mainDocumentURL'] != null
? Uri.tryParse(map['mainDocumentURL']) ? WebUri(map['mainDocumentURL'])
: null, : null,
assumesHTTP3Capable: map['assumesHTTP3Capable'], assumesHTTP3Capable: map['assumesHTTP3Capable'],
attribution: URLRequestAttribution.fromNativeValue(map['attribution']), attribution: URLRequestAttribution.fromNativeValue(map['attribution']),

View File

@ -1,12 +1,14 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../web_uri.dart';
part 'url_response.g.dart'; part 'url_response.g.dart';
///The metadata associated with the response to a URL load request, independent of protocol and URL scheme. ///The metadata associated with the response to a URL load request, independent of protocol and URL scheme.
@ExchangeableObject() @ExchangeableObject()
class URLResponse_ { class URLResponse_ {
///The URL for the response. ///The URL for the response.
Uri? url; WebUri? url;
///The expected length of the responses content. ///The expected length of the responses content.
int expectedContentLength; int expectedContentLength;

View File

@ -9,7 +9,7 @@ part of 'url_response.dart';
///The metadata associated with the response to a URL load request, independent of protocol and URL scheme. ///The metadata associated with the response to a URL load request, independent of protocol and URL scheme.
class URLResponse { class URLResponse {
///The URL for the response. ///The URL for the response.
Uri? url; WebUri? url;
///The expected length of the responses content. ///The expected length of the responses content.
int expectedContentLength; int expectedContentLength;
@ -43,7 +43,7 @@ class URLResponse {
return null; return null;
} }
final instance = URLResponse( final instance = URLResponse(
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
expectedContentLength: map['expectedContentLength'], expectedContentLength: map['expectedContentLength'],
mimeType: map['mimeType'], mimeType: map['mimeType'],
suggestedFilename: map['suggestedFilename'], suggestedFilename: map['suggestedFilename'],

View File

@ -2,6 +2,7 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
import 'web_history.dart'; import 'web_history.dart';
part 'web_history_item.g.dart'; part 'web_history_item.g.dart';
@ -11,13 +12,13 @@ part 'web_history_item.g.dart';
@ExchangeableObject() @ExchangeableObject()
class WebHistoryItem_ { class WebHistoryItem_ {
///Original url of this history item. ///Original url of this history item.
Uri? originalUrl; WebUri? originalUrl;
///Document title of this history item. ///Document title of this history item.
String? title; String? title;
///Url of this history item. ///Url of this history item.
Uri? url; WebUri? url;
///0-based position index in the back-forward [WebHistory.list]. ///0-based position index in the back-forward [WebHistory.list].
int? index; int? index;

View File

@ -10,13 +10,13 @@ part of 'web_history_item.dart';
///Each [WebHistoryItem] is a snapshot of the requested history item. ///Each [WebHistoryItem] is a snapshot of the requested history item.
class WebHistoryItem { class WebHistoryItem {
///Original url of this history item. ///Original url of this history item.
Uri? originalUrl; WebUri? originalUrl;
///Document title of this history item. ///Document title of this history item.
String? title; String? title;
///Url of this history item. ///Url of this history item.
Uri? url; WebUri? url;
///0-based position index in the back-forward [WebHistory.list]. ///0-based position index in the back-forward [WebHistory.list].
int? index; int? index;
@ -33,9 +33,9 @@ class WebHistoryItem {
} }
final instance = WebHistoryItem( final instance = WebHistoryItem(
originalUrl: originalUrl:
map['originalUrl'] != null ? Uri.tryParse(map['originalUrl']) : null, map['originalUrl'] != null ? WebUri(map['originalUrl']) : null,
title: map['title'], title: map['title'],
url: map['url'] != null ? Uri.tryParse(map['url']) : null, url: map['url'] != null ? WebUri(map['url']) : null,
index: map['index'], index: map['index'],
offset: map['offset'], offset: map['offset'],
); );

View File

@ -1,6 +1,7 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import '../web_uri.dart';
part 'web_resource_request.g.dart'; part 'web_resource_request.g.dart';
@ -8,7 +9,7 @@ part 'web_resource_request.g.dart';
@ExchangeableObject() @ExchangeableObject()
class WebResourceRequest_ { class WebResourceRequest_ {
///The URL for which the resource request was made. ///The URL for which the resource request was made.
Uri url; WebUri url;
///The headers associated with the request. ///The headers associated with the request.
/// ///

View File

@ -9,7 +9,7 @@ part of 'web_resource_request.dart';
///Class representing a resource request of the [WebView]. ///Class representing a resource request of the [WebView].
class WebResourceRequest { class WebResourceRequest {
///The URL for which the resource request was made. ///The URL for which the resource request was made.
Uri url; WebUri url;
///The headers associated with the request. ///The headers associated with the request.
/// ///
@ -52,7 +52,7 @@ class WebResourceRequest {
return null; return null;
} }
final instance = WebResourceRequest( final instance = WebResourceRequest(
url: (Uri.tryParse(map['url']) ?? Uri()), url: WebUri(map['url']),
headers: map['headers']?.cast<String, String>(), headers: map['headers']?.cast<String, String>(),
method: map['method'], method: map['method'],
hasGesture: map['hasGesture'], hasGesture: map['hasGesture'],

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/src/web_uri.dart';
import 'dart:html'; import 'dart:html';
import 'dart:js' as js; import 'dart:js' as js;
@ -344,7 +345,7 @@ class InAppWebViewWebElement implements Disposable {
{required String url, required Uint8List postData}) async { {required String url, required Uint8List postData}) async {
await loadUrl( await loadUrl(
urlRequest: urlRequest:
URLRequest(url: Uri.tryParse(url), method: "POST", body: postData)); URLRequest(url: WebUri(url), method: "POST", body: postData));
} }
Future<void> injectJavascriptFileFromUrl( Future<void> injectJavascriptFileFromUrl(

View File

@ -7,11 +7,12 @@ import '../debug_logging_settings.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../types/disposable.dart'; import '../types/disposable.dart';
import '../web_uri.dart';
import 'web_authenticate_session_settings.dart'; import 'web_authenticate_session_settings.dart';
///A completion handler for the [WebAuthenticationSession]. ///A completion handler for the [WebAuthenticationSession].
typedef WebAuthenticationSessionCompletionHandler = Future<void> Function( typedef WebAuthenticationSessionCompletionHandler = Future<void> Function(
Uri? url, WebAuthenticationSessionError? error)?; WebUri? url, WebAuthenticationSessionError? error)?;
///A session that an app uses to authenticate a user through a web service. ///A session that an app uses to authenticate a user through a web service.
/// ///
@ -44,7 +45,7 @@ class WebAuthenticationSession implements Disposable {
late final String id; late final String id;
///A URL with the `http` or `https` scheme pointing to the authentication webpage. ///A URL with the `http` or `https` scheme pointing to the authentication webpage.
final Uri url; final WebUri url;
///The custom URL scheme that the app expects in the callback URL. ///The custom URL scheme that the app expects in the callback URL.
final String? callbackURLScheme; final String? callbackURLScheme;
@ -67,7 +68,7 @@ class WebAuthenticationSession implements Disposable {
/// ///
///[onComplete] represents a completion handler the session calls when it completes successfully, or when the user cancels the session. ///[onComplete] represents a completion handler the session calls when it completes successfully, or when the user cancels the session.
static Future<WebAuthenticationSession> create( static Future<WebAuthenticationSession> create(
{required Uri url, {required WebUri url,
String? callbackURLScheme, String? callbackURLScheme,
WebAuthenticationSessionCompletionHandler onComplete, WebAuthenticationSessionCompletionHandler onComplete,
WebAuthenticationSessionSettings? initialSettings}) async { WebAuthenticationSessionSettings? initialSettings}) async {
@ -129,7 +130,7 @@ class WebAuthenticationSession implements Disposable {
switch (call.method) { switch (call.method) {
case "onComplete": case "onComplete":
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.tryParse(url) : null; WebUri? uri = url != null ? WebUri(url) : null;
var error = WebAuthenticationSessionError.fromNativeValue( var error = WebAuthenticationSessionError.fromNativeValue(
call.arguments["errorCode"]); call.arguments["errorCode"]);
if (onComplete != null) { if (onComplete != null) {

View File

@ -1,6 +1,7 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import '../in_app_webview/in_app_webview_controller.dart'; import '../in_app_webview/in_app_webview_controller.dart';
import '../types/main.dart'; import '../types/main.dart';
import '../web_uri.dart';
///This listener receives messages sent on the JavaScript object which was injected by [InAppWebViewController.addWebMessageListener]. ///This listener receives messages sent on the JavaScript object which was injected by [InAppWebViewController.addWebMessageListener].
/// ///
@ -59,8 +60,8 @@ class WebMessageListener {
} }
if (onPostMessage != null) { if (onPostMessage != null) {
String? message = call.arguments["message"]; String? message = call.arguments["message"];
Uri? sourceOrigin = call.arguments["sourceOrigin"] != null WebUri? sourceOrigin = call.arguments["sourceOrigin"] != null
? Uri.tryParse(call.arguments["sourceOrigin"]) ? WebUri(call.arguments["sourceOrigin"])
: null; : null;
bool isMainFrame = call.arguments["isMainFrame"]; bool isMainFrame = call.arguments["isMainFrame"];
onPostMessage!(message, sourceOrigin, isMainFrame, _replyProxy!); onPostMessage!(message, sourceOrigin, isMainFrame, _replyProxy!);

200
lib/src/web_uri.dart Normal file
View File

@ -0,0 +1,200 @@
///Class that implements the [Uri] interface to maintain also the raw string value used by [Uri.parse].
///
///This class is used because some strings coming from the native platform side
///are not parsed correctly or could lose letter case information,
///so [rawValue] can be used as a fallback value.
///
///Examples:
///```dart
/// // InAppWebView example
/// InAppWebView(
/// initialUrlRequest:
/// URLRequest(url: WebUri('https://flutter.dev'))
/// )
///
/// // example of letter case difference
/// final uri = WebUri('scheme://customHostValue', forceToStringRawValue: false);
/// print(uri.rawValue); // scheme://customHostValue
/// print(uri.isValidUri); // true
/// print(uri.uriValue.toString()); // scheme://customhostvalue
/// print(uri.toString()); // scheme://customhostvalue
///
/// uri.forceToStringRawValue = true;
/// print(uri.toString()); // scheme://customHostValue
///
/// // example of a not valid URI
/// // Uncaught Error: FormatException: Invalid port (at character 14)
/// final invalidUri = WebUri('intent://not:valid_uri');
/// print(invalidUri.rawValue); // intent://not:valid_uri
/// print(invalidUri.isValidUri); // false
/// print(invalidUri.uriValue.toString()); // ''
/// print(invalidUri.toString()); // intent://not:valid_uri
///```
class WebUri implements Uri {
Uri _uri = Uri();
String _rawValue = '';
bool _isValidUri = false;
///Whether to force the usage of [rawValue] when calling [toString] or not.
///Because [toString] is used to send URI strings to the native platform side,
///this flag is useful when you want to send [rawValue] instead of [uriValue]`.toString()`.
///
///The default value is `false`.
bool forceToStringRawValue = false;
///Initialize a [WebUri] using a raw string value.
///In this case, [uriValue]`.toString()` and [rawValue] could not have the same value.
WebUri(String source, {this.forceToStringRawValue = false}) {
_rawValue = source;
try {
_uri = Uri.parse(this._rawValue);
_isValidUri = true;
} catch (e, stacktrace) {
print(e);
print(stacktrace);
}
}
///Initialize a [WebUri] using an [Uri] instance.
///In this case, [uriValue]`.toString()` and [rawValue] will have the same value.
WebUri.uri(Uri uri) {
_uri = uri;
_rawValue = uri.toString();
_isValidUri = true;
}
///Raw string value used by [Uri.parse].
String get rawValue => _rawValue;
///Uri parsed value. If [isValidUri] is `false`, the value will be `Uri()`.
Uri get uriValue => _uri;
///`true` if [rawValue] has been parsed correctly, otherwise `false`.
bool get isValidUri => _isValidUri;
@override
String get authority => _uri.authority;
@override
UriData? get data => _uri.data;
@override
String get fragment => _uri.fragment;
@override
bool get hasAbsolutePath => _uri.hasAbsolutePath;
@override
bool get hasAuthority => _uri.hasAuthority;
@override
bool get hasEmptyPath => _uri.hasEmptyPath;
@override
bool get hasFragment => _uri.hasFragment;
@override
bool get hasPort => _uri.hasPort;
@override
bool get hasQuery => _uri.hasQuery;
@override
bool get hasScheme => _uri.hasScheme;
@override
String get host => _uri.host;
@override
bool get isAbsolute => _uri.isAbsolute;
@override
bool isScheme(String scheme) {
return _uri.isScheme(scheme);
}
@override
Uri normalizePath() {
return _uri.normalizePath();
}
@override
String get origin => _uri.origin;
@override
String get path => _uri.path;
@override
List<String> get pathSegments => _uri.pathSegments;
@override
int get port => _uri.port;
@override
String get query => _uri.query;
@override
Map<String, String> get queryParameters => _uri.queryParameters;
@override
Map<String, List<String>> get queryParametersAll => _uri.queryParametersAll;
@override
Uri removeFragment() {
return _uri.removeFragment();
}
@override
Uri replace(
{String? scheme,
String? userInfo,
String? host,
int? port,
String? path,
Iterable<String>? pathSegments,
String? query,
Map<String, dynamic>? queryParameters,
String? fragment}) {
return _uri.replace(
scheme: scheme,
userInfo: userInfo,
host: host,
port: port,
path: path,
pathSegments: pathSegments,
query: query,
queryParameters: queryParameters,
fragment: fragment);
}
@override
Uri resolve(String reference) {
return _uri.resolve(reference);
}
@override
Uri resolveUri(Uri reference) {
return _uri.resolveUri(reference);
}
@override
String get scheme => _uri.scheme;
@override
String toFilePath({bool? windows}) {
return _uri.toFilePath(windows: windows);
}
@override
String get userInfo => _uri.userInfo;
///If [forceToStringRawValue] is `true` or [isValidUri] is `false`, it returns [rawValue],
///otherwise the value of [uriValue]`.toString()`.
@override
String toString() {
return forceToStringRawValue || !_isValidUri ? _rawValue : _uri.toString();
}
@override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

View File

@ -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.9 version: 6.0.0-beta.10
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