GuardStack class

Compose multiple guards into a single guard.

Executes guards in order until one returns GuardResult.handled or all return GuardResult.next.

Example:

// Create reusable guard combinations
final adminGuards = GuardStack([
  AuthGuard(),
  RoleGuard(['admin']),
  AuditLogGuard(),
]);

router.route(
  AdminPage.path,
  (_) => AdminPage(),
  routeGuards: [adminGuards],
);
Inheritance

Constructors

GuardStack(List<NyRouteGuard> guards)

Properties

context → BuildContext?
Convenience getter for the build context.
no setterinherited
data → dynamic
Convenience getter for the route data.
no setterinherited
guards → List<NyRouteGuard>
The guards to execute in order.
final
hashCode → int
The hash code for this object.
no setterinherited
hasModifiedData → bool
Whether setData was called during this guard's execution.
no setterinherited
modifiedData → dynamic
Get modified data if setData was called.
no setterinherited
pageRequest ↔ PageRequest?
getter/setter pairinherited
queryParameters → Map<String, String>
Convenience getter for query parameters.
no setterinherited
redirectConfig → RedirectConfig?
Get the redirect configuration if a redirect was requested.
no setterinherited
routeContext → RouteContext?
The current route context.
no setterinherited
routeName → String?
Convenience getter for the route name.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

abort() → GuardResult
Abort navigation without redirecting.
inherited
next() → GuardResult
Continue to the next guard or to the route.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAfter(RouteContext context) → Future<void>
Called after successful navigation to the route.
override
onBefore(RouteContext context) → Future<GuardResult>
Called before navigation to the route.
override
onRequest(PageRequest pageRequest) → Future<PageRequest?>
Legacy method override for backward compatibility. Delegates to the new onBefore lifecycle method.
inherited
redirect(Object path, {dynamic data, Map<String, dynamic>? queryParameters, NavigationType navigationType = NavigationType.pushReplace, dynamic result, bool removeUntilPredicate(Route route)?, TransitionType? transitionType, dynamic onPop(dynamic value)?}) → GuardResult
Redirect to a different route.
inherited
setData(dynamic data) → void
Modify the data passed to subsequent guards and the route.
inherited
setRouteContext(RouteContext context) → void
Set the route context. Called by the router.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited