shouldInterceptAjaxRequest property

(Future<AjaxRequest?> Function(T controller, AjaxRequest ajaxRequest)?) shouldInterceptAjaxRequest
final

Event fired when an XMLHttpRequest is sent to a server. It gives the host application a chance to take control over the request before sending it.

Due to the async nature of this event implementation, it will intercept only async XMLHttpRequests (AjaxRequest.isAsync with true). To be able to intercept sync XMLHttpRequests, use InAppWebViewSettings.interceptOnlyAsyncAjaxRequests to false.

ajaxRequest represents the XMLHttpRequest.

NOTE: In order to be able to listen this event, you need to set InAppWebViewSettings.useShouldInterceptAjaxRequest setting to true. Also, unlike iOS that has WKUserScript that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). Inside the window.addEventListener("flutterInAppWebViewPlatformReady") event, the ajax requests will be intercept for sure.

Officially Supported Platforms/Implementations:

  • Android native WebView
  • iOS
  • MacOS

Implementation

final Future<AjaxRequest?> Function(T controller, AjaxRequest ajaxRequest)?
    shouldInterceptAjaxRequest;