ConditionalGuard class

Conditionally apply a guard based on a predicate.

Example:

ConditionalGuard(
  condition: (context) => context.routeName.startsWith('/admin'),
  guard: AdminGuard(),
)
Inheritance

Constructors

ConditionalGuard({required bool condition(RouteContext context), required NyRouteGuard guard})

Properties

condition bool Function(RouteContext context)
The condition to check.
final
context BuildContext?
Convenience getter for the build context.
no setterinherited
data → dynamic
Convenience getter for the route data.
no setterinherited
guard NyRouteGuard
The guard to apply if condition is true.
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