requestLoading 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 requestLoading(
android_webview.WebView webView,
android_webview.WebResourceRequest request,
) {
if (!handlesNavigation) {
return;
}
final FutureOr<bool> returnValue = onNavigationRequestCallback!(
url: request.url,
isForMainFrame: request.isForMainFrame,
);
if (returnValue is bool && returnValue) {
loadUrl!(request.url, <String, String>{});
} else if (returnValue is Future<bool>) {
returnValue.then((bool shouldLoadUrl) {
if (shouldLoadUrl) {
loadUrl!(request.url, <String, String>{});
}
});
}
}