shouldOverrideUrlLoading method

  1. @override
Future<NavigationActionPolicy?>? shouldOverrideUrlLoading(
  1. NavigationAction navigationAction
)
override

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 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 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 InAppWebViewSettings.useShouldOverrideUrlLoading setting to true.

Officially Supported Platforms/Implementations:

Implementation

@override
Future<NavigationActionPolicy?>? shouldOverrideUrlLoading(
    NavigationAction navigationAction) {
  return null;
}