onRedirect method

  1. @protected
GuardResult onRedirect(
  1. RouteNode origin,
  2. RouteNode target,
  3. Map<String, Object> context,
  4. int redirectCount,
)

Invoked when the redirect counter reaches maxRedirects.

The default implementation returns GuardResult.cancel. Override in subclasses to customise the behaviour (for example, to redirect to an error route).

Implementation

@protected
GuardResult onRedirect(
  RouteNode origin,
  RouteNode target,
  Map<String, Object> context,
  int redirectCount,
) =>
    const GuardResult.cancel(reason: 'Max redirects reached');