shouldOverrideUrlLoading property

Future<NavigationActionPolicy?> Function(T 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.

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 InAppWebViewSettings.regexToCancelSubFramesLoading setting 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 event 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 InAppWebViewSettings.useShouldOverrideUrlLoading setting to true. Also, on Android this event is not called on the first page load.

Officially Supported Platforms/Implementations:

Implementation

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