RouteGuard class abstract
Abstract base class for route guards.
Implement this to create custom guards for authentication, authorization, data prefetching, etc.
Example:
class AuthGuard extends RouteGuard {
@override
Future<GuardResult> canActivate(RouteLocation to, RouteLocation from) async {
if (!isLoggedIn) {
return GuardRedirect('/login');
}
return const GuardAllow();
}
}
Constructors
- RouteGuard()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canActivate(
RouteLocation to, RouteLocation from) → Future< GuardResult> - Called before navigating TO a route.
-
canDeactivate(
RouteLocation to, RouteLocation from) → Future< bool> - Called before navigating AWAY from a route.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
RouteLocation to) → Future< Map< String, dynamic> ?> - Resolve/prefetch data before the route activates.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited