router library

The owlet_router serves as a router manager, utilizing the route builder to create the router. It allows you to build your router as a module tree, with each field of the object representing a branch, making it easy to obtain the router path.

Classes

AwareExistsRoute<A extends Object?, T extends Object?>
This route will be automatically skipped if it already exists in the navigator. Override onRouteExists to handle this scenario or perform custom actions.
CancelledRoute<T extends Object?>
In RouteGuardFunction, returns CancelledRoute to cancel the pushing.
CupertinoRouteBuilder<A extends Object?, T extends Object?>
Construct a route with the CupertinoPageRoute. The RouteBuilder class also defines the parameter type (A) and the result type (T) of the route. However, in certain scenarios, the parameter verification mechanism may fail to function properly.
DefaultFinderWithCache
In cache mode, the finder's result will be cached for the next time.
DefaultRouteFinder
The finder uses the A* search algorithm to find the route that matches the path.
GuardProxyRoute<R extends RouteBuilderMixin<Object?, Object?>>
Implement the build function of the route guard in a way that combines all the guard methods in case of a nested route. The execution order should follow a top-down approach, starting from the outermost route and progressing inwards. The result of each outer guard method should be passed as a parameter to the next inner guard method.
MaterialRouteBuilder<A extends Object?, T extends Object?>
Construct a route with the MaterialRouteBuilder. The RouteBuilder class also defines the parameter type (A) and the result type (T) of the route. However, in certain scenarios, the parameter verification mechanism may fail to function properly.
NamedFunctionRouteBuilder<A extends Object?, T extends Object?>
The OwletNavigator provides a feature that allows you to name a function and call it using Navigator.pushNamed, returning the function's result as the push result.
NamedFunctionRouteSettings<T extends Object?>
The OwletNavigator utilizes the NamedFunctionRouteSettings class to identify named function routes. Additionally, it relays the callback for the processed function
The navigation service exposes Owlet Router information.
NestedRoute<R extends RouteBuilderMixin<Object?, Object?>>
Similar to a nested navigator, nested routes facilitate the division of a route into two components. The actual route gets injected into the navigation service, while the remaining segment serves as an argument for the page widget.
NestedService<R extends RouteBuilderMixin<Object?, Object?>, S extends RouteBase>
In case using multiple NavigationService, this route will create a link between the route's NavigationService with NestedService.nestedService. If this route does not exist in Navigator, it will be opened. Else, the route will be passed into NestedService.nestedService. The duplicate or start with route with NestedService.path will be ignored.
NoTransitionPageRoute<T>
Construct a PageRoute without effects when pushing.
NoTransitionRouteBuilder<A extends Object?, T extends Object?>
Construct a route with the NoTransitionPageRoute. The RouteBuilder class also defines the parameter type (A) and the result type (T) of the route. However, in certain scenarios, the parameter verification mechanism may fail to function properly.
OwletDelegate<R extends RouteMixin>
Implementing a RouterDelegate using RouteBuilder.
OwletInformationParser
A RouteInformationParser to parse between RouteBase and RouteInformation
OwletNavigator
Implementation of advanced navigation features for the Navigator, including route guards and named route builders. These features, such as RouteGuard and NamedFunctionRouteBuilder, are only active when used within the OwletNavigator.
OwletNavigatorState
This is the state of OwletNavigator
PlaceholderRouteBuilder<A extends Object?, T extends Object?>
At times, the RouteGuard solely relies on the route within the RouteGuard.routeGuard result. For such cases, the PlaceholderRouteBuilder provides a way to map this situation when the RouteBuilder doesn't need to specify anything else
ProxyRoute<R extends RouteMixin>
This object enables the nesting of one route within another. In some cases, a route (such as RouteGuard or NestedService) will not directly construct a route. Instead, it will perform intermediary steps before constructing the final route. The ProxyRoute component can facilitate the management of nested routes, including preventing excessively deep nesting.
RedirectRoute<T extends Object?>
In RouteGuardFunction, returns RedirectRoute to redirect the pushing to another route's name
RouteBase
A RouteBase class represents a path segment that must start with a slash (/). The parent field of a RouteBase instance is lazily updated at runtime when it has been defined in RouteBase.children. A RouteBase instance can only have one parent; attempting to update an existing RouteBase.parent property to a new value will result in an error.
RouteBuilder<A extends Object?, T extends Object?>
Construct a route using its path. Each path must be uniquely associated with a single route. The RouteBuilder class also defines the parameter type (A) and the result type (T) of the route. However, in certain scenarios, the parameter verification mechanism may fail to function properly. The builder function can either be defined directly in the constructor or by overriding the Route<T>? build(RouteSettings settings) method.
RouteFinderDelegate
Provides the method to find a route in the router that matches to path.
RouteGuard<A extends Object?, T extends Object?>
Within the OwletNavigator, when a route is pushed, the RouteGuardSettings.routeGuard function is invoked if the route has settings as RouteGuardSettings type. This function's returned value determines the pushing behavior.
RouteGuardSettings
Within the OwletNavigator, when a route is pushed, the RouteGuardSettings.routeGuard function is invoked if the route has settings as RouteGuardSettings type.
RouteIndex
The result of RouteHistory.nearest includes a route and its corresponding position. When the position is equal to 0, the route is the current route.
RouteMixin
A RouteBase class represents a path segment that must start with a slash (/). The parent field of a RouteBase instance is lazily updated at runtime when it has been defined in RouteBase.children. A RouteBase instance can only have one parent; attempting to update an existing RouteBase.parent property to a new value will result in an error.
RouteNotifier
Notify when a route is pushed, setting the notifier's value to the pushed route's settings.

Mixins

ConvertToNoTransitionBuilderMixin<A extends Object?, T extends Object?>
Convert a RouteBuilder into a NoTransitionPageRoute
PageRouteMixin
To implement a PageRoute within RouteBuilder, some fields are required. The PageRouteMixin provides the interface for this.
RouteBuilderMixin<A extends Object?, T extends Object?>
A route can be built (or called to an action)
RouteHistory
Log the current route stack as a list, with the last route in the list being the top-most route.

Extensions

Extension for NavigationService to push a route with its context.
RouteListOut on RouteMixin
The function lists all the routes and their children, which are solely intended for the developer preview of router information.
RouterExtension on RouteBuilderMixin<A, T>
RouteBuilder extension to push a route. The A argument defines the route's argument type, and the T argument defines the route's result type.
RouteSettingsReader on RouteSettings
Extension to read the URI from the name.

Properties

owletDefaultUnknownRoute MaterialRouteBuilder<Object?, Object?>
The default unknown route builder, which is used when the specified route cannot be found or the route builder returns a null route.
final

Functions

compareName(String? a, String? b) bool
Return true if the a path and b path are the same. If either or both of them are null or cannot be parsed into a valid URI, then return false.
compareRouteName(Route a, Route b) bool
Return true if the a path and b path are the same. If either or both of them are null or cannot be parsed into a valid URI, then return false.
compareRouteNameWithArgument(Route a, Route b) bool
Return true if the a and b are the same URI and arguments. If either or both of them are null or cannot be parsed into a valid URI, then return false.
compareRouteWithRouteMixin(Route a, RouteMixin b) bool
Return true if the a path and b path are the same. If either or both of them are null or cannot be parsed into a valid URI, then return false.
mapToQueryParameter(Map<String, Object?> args, {bool encode = false, String? fragment}) String
Constructs the URI's query parameters from a Map<String, Object?>. When the encoding flag is set to true, the parameters are encoded using the URI encoder.
owletDefaultPlaceholder(BuildContext context, RouteSettings settings) Widget
Build a blank page.
routesToString(Iterable<RouteMixin> list) String
Convert the list of RouteMixin to String

Typedefs

PageBuilder = Widget Function(BuildContext context, RouteSettings settings)
Build a page with context and route settings.
RouteBuilderFunction<R> = Route<R>? Function(RouteSettings settings)
Build the route with the RouteSettings.
RouteCallback<R> = FutureOr<R?> Function(BuildContext context, Route<R?> route)
The callback function for the push method receives the context of the push operation and the corresponding route.
RouteGuardFunction = FutureOr<Route?> Function(BuildContext context, RouteBuilderMixin<Object?, Object?> it, Route route)
The pre-push function's return value determines the route pushing behavior.