NyRouteGuard class

Base class for Nylo's RouteGuard.

Usage:

  1. Create a new class that extends RouteGuard. class AuthRouteGuard extends NyRouteGuard { AuthRouteGuard();

@override Future<PageRequest?> onRequest(PageRequest pageRequest) async {

// Check if user is authenticated
if (await Auth.loggedIn()) {
  return redirect(HomePage.path);
}

return pageRequest;

} }

  1. Add the new RouteGuard to your route. appRouter() => nyRoutes((router) {

router.route(ProfilePage.path, (context) => ProfilePage(), routeGuards: AuthRouteGuard() // new guard );

});

Inheritance

Constructors

NyRouteGuard()

Properties

context BuildContext?
The BuildContext for the current route.
no setter
data → dynamic
The NyArgument passed from the last route.
no setter
hashCode int
The hash code for this object.
no setterinherited
pageRequest PageRequest?
getter/setter pairinherited
queryParameters Map<String, String>?
The NyQueryParameters for the current route.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addData(dynamic currentData(dynamic data)) → dynamic
Add data to the current route.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onRequest(PageRequest pageRequest) → dynamic
Called before a route is opened.
override
redirect(dynamic path, {dynamic data, Map<String, dynamic>? queryParameters, NavigationType navigationType = NavigationType.pushReplace, dynamic result, bool removeUntilPredicate(Route route)?, PageTransitionSettings? pageTransitionSettings, PageTransitionType? pageTransitionType, dynamic onPop(dynamic value)?}) → dynamic
Redirect to a new route.
toString() String
A string representation of this object.
inherited

Operators

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