shouldInterceptRequest method

  1. @override
FutureOr<WebResourceResponse?>? shouldInterceptRequest(
  1. WebResourceRequest request
)
inherited

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 event 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, check the InAppWebViewSettings.useShouldInterceptRequest setting documentation.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • request: all platforms

Use the PlatformInAppBrowserEvents.isMethodSupported method to check if this method is supported at runtime.

Implementation

@override
FutureOr<WebResourceResponse?>? shouldInterceptRequest(
  WebResourceRequest request,
) {
  return null;
}