redirect property

GoRouterRedirect redirect
final

The top-level callback allows the app to redirect to a new location.

Alternatively, you can specify a redirect for an individual route using GoRoute.redirect. If BuildContext.dependOnInheritedWidgetOfExactType is used during the redirection (which is how of methods are usually implemented), a re-evaluation will be triggered when the InheritedWidget changes.

This legacy callback remains supported alongside onEnter. If both are provided, onEnter executes first and may block the navigation. When allowed, this callback runs once per navigation cycle before any route-level redirects.

Implementation

final GoRouterRedirect redirect;