NyRouteGuard class
Base class for Nylo's RouteGuard.
Usage:
- Create a new class that extends RouteGuard. class AuthRouteGuard extends NyRouteGuard { AuthRouteGuard();
@override Future
@override redirectTo(BuildContext? context, NyArgument? data) async { // routeTo a page if canOpen fails. await routeTo(HomePage.path); } }
- Add the new RouteGuard to your route. appRouter() => nyRoutes((router) {
router.route(ProfilePage.path, (context) => ProfilePage(), routeGuards:
AuthRouteGuard() // new guard
);
});
- Inheritance
-
- Object
- RouteGuard
- NyRouteGuard
Constructors
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
-
canOpen(
BuildContext? context, NyArgument? data) → Future< bool> -
Return true if the User can access this page and false if they can't.
canOpen will contain the
context
and any arguments passed from the last route.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
redirectTo(
BuildContext? context, NyArgument? data) → Future< void> -
This method is called after the canOpen returns false.
Provide an action that should occur.
E.g. routeTo('login');
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited