GuardResult class
Represents the result of evaluating a route navigation guard.
Returned by BloomRouteGuard.canActivate. A guard result determines whether
navigation to a target route is permitted to proceed (isAllowed is true)
or must be redirected to an alternate path (redirectPath).
When a guard returns a redirect, client routers halt navigation to the requested path and instead navigate to redirectPath.
class AuthGuard extends BloomRouteGuard {
final bool isLoggedIn;
const AuthGuard(this.isLoggedIn);
@override
GuardResult canActivate(String location, Map<String, String> params) {
if (!isLoggedIn) {
return GuardResult.redirect('/login');
}
return GuardResult.allow();
}
}
Constructors
- GuardResult.allow()
-
Creates a guard result permitting navigation to proceed.
factory
- GuardResult.deny()
-
Creates a guard result that blocks navigation without redirecting.
factory
- GuardResult.redirect(String path)
-
Creates a guard result that cancels the current navigation and redirects to
path.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAllowed → bool
-
Whether navigation to the target route is permitted to proceed.
final
- redirectPath → String?
-
Target path to redirect to when navigation is disallowed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited