shouldOverrideUrlLoading property

(Future<NavigationActionPolicy?> Function(InAppWebViewController controller, NavigationAction navigationAction)?) shouldOverrideUrlLoading
final

Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView.

Note that on Android there isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. However, if you want to cancel requests for subframes, you can use the AndroidInAppWebViewOptions.regexToCancelSubFramesLoading option to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled.

Also, on Android, this method is not called for POST requests.

navigationAction represents an object that contains information about an action that causes navigation to occur.

NOTE: In order to be able to listen this event, you need to set InAppWebViewOptions.useShouldOverrideUrlLoading option to true. Also, on Android this event is not called on the first page load.

Official Android API: https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)

Official iOS API: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview

Implementation

final Future<NavigationActionPolicy?> Function(
        InAppWebViewController controller, NavigationAction navigationAction)?
    shouldOverrideUrlLoading;