shouldInterceptRequest method
Notify the host application of a resource request and allow the application to return the data.
If the return value is null
, the WebView will continue to load the resource as usual.
Otherwise, the return response and data will be used.
This callback is invoked for a variety of URL schemes (e.g., http(s):
, data:
, file:
, etc.),
not only those schemes which send requests over the network.
This is not called for javascript:
URLs, blob:
URLs, or for assets accessed via file:///android_asset/
or file:///android_res/
URLs.
In the case of redirects, this is only called for the initial resource URL, not any subsequent redirect URLs.
request
Object containing the details of the request.
NOTE: In order to be able to listen this event, you need to set InAppWebViewSettings.useShouldInterceptRequest option to true
.
Officially Supported Platforms/Implementations:
- Android native WebView (Official API - WebViewClient.shouldInterceptRequest)
Implementation
@override
Future<WebResourceResponse?>? shouldInterceptRequest(
WebResourceRequest request) {
return null;
}