NyRouter class

NyRouterRoute manages routing, registering routes with transitions, navigating to routes, closing routes. It is a thin layer on top of Navigator to help you encapsulate and manage routing at one place.

Constructors

NyRouter({NyRouterOptions options = const NyRouterOptions()})

Properties

hashCode int
The hash code for this object.
no setterinherited
no setter
options NyRouterOptions
Configuration options for NyRouterRoute.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(RouteView routeView, {PageTransitionType? transition, PageTransitionSettings? pageTransitionSettings, List<NyRouteGuard>? routeGuards, bool initialRoute = false, bool unknownRoute = false, bool authenticatedRoute = false}) NyRouterRoute
Add a new route with a RouteView.
addRouteHistory(Route route) → dynamic
Add the route to the history.
addRoutes(List<NyRouterRoute> routes) → void
Add a list of routes at once.
containsRoutes(List<String> routes) bool
Check if the router contains the routes.
generator({Widget builder(BuildContext context, Widget widget)?}) RouteFactory
Generates the RouteFactory which builds a Route on request.
getAuthRouteName() String?
Retrieves the auth route name from your router.
getCurrentRoute() Route?
Get the current route.
getInitialRouteName() String
Retrieves the initial route name from your router.
getPreviousRoute() Route?
Get the previous route.
getRegisteredRouteNames() List<String>
Get the registered routes names as a list.
getRegisteredRoutes() Map<String, NyRouterRoute>
Get the registered routes as a list.
getRouteHistory() List<Route>
Get the route history.
getUnknownRouteName() String
Retrieves the unknown route name from your router.
getUnknownRoutes() Map<String, NyRouterRoute>
Get the unknown routes as a list.
group(Map<String, dynamic> settings(), dynamic router(NyRouter router)) → dynamic
Group routes settings is a function that returns a map of settings. router is a function that returns a router. Example:
isRouteNamedArg(String name) bool
Check if the route is a named argument.
Function used to navigate pages.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeLastRouteHistory() → dynamic
Remove the last route from the history.
removeRouteHistory(Route route) → dynamic
Remove the route from the history.
route(String name, NyRouteView view, {PageTransitionType? transition, PageTransitionSettings? pageTransitionSettings, List<NyRouteGuard>? routeGuards, bool initialRoute = false, bool unknownRoute = false, bool authenticatedRoute = false}) NyRouterRoute
Add a new route with a widget.
routeNameMappingsContains(String name) bool
Checks if the route name mappings contain a route name.
setNyRoutes(NyRouter router) → void
Set the registered routes.
setRegisteredRoutes(Map<String, NyRouterRoute> routes) → void
Set the registered routes.
setUnknownRoutes(Map<String, NyRouterRoute> routes) → void
Set the unknown routes.
toString() String
A string representation of this object.
inherited
unknownRoute({Widget builder(BuildContext context, Widget widget)?}) RouteFactory
Generates the RouteFactory for unknown routes.
updateRegisteredRoutes(Map<String, NyRouterRoute> router) → dynamic
Update the registered routes.
updateRoute(NyRouterRoute route) → dynamic
Updates a named route.

Operators

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

Static Methods

args<T extends NyArgument?>(BuildContext context) → T?
Retrieves the arguments passed in when calling the navigate function.
getInitialRoute() String
Find the initial route.
getUnknownRoute() NyRouterRoute
Find the unknown route.
unknownRouteGenerator() RouteFactory
Unknown route generator.