urlLoading method
When a URL is about to be loaded in the current WebView
.
If a WebViewClient
is not provided, by default WebView
will ask
Activity Manager to choose the proper handler for the URL. If a
WebViewClient
is provided, setting shouldOverrideUrlLoading to true
causes the current WebView
to abort loading the URL, while returning
false causes the WebView
to continue loading the URL as usual.
Implementation
@override
void urlLoading(android_webview.WebView webView, String url) {
if (!handlesNavigation) {
return;
}
final FutureOr<bool> returnValue = onNavigationRequestCallback!(
url: url,
isForMainFrame: true,
);
if (returnValue is bool && returnValue) {
loadUrl!(url, <String, String>{});
} else {
(returnValue as Future<bool>).then((bool shouldLoadUrl) {
if (shouldLoadUrl) {
loadUrl!(url, <String, String>{});
}
});
}
}