VGuard class
VGuard is a VRouteElement which is used to control navigation changes
Use beforeEnter, beforeLeave or beforeUpdate to get navigation changes before they take place. These methods will give you a VRedirector that you can use to:
- know about the navigation changes VRedirector.previousVRouterData and VRedirector.newVRouterData
- redirect using VRedirector.to or stop the navigation using VRedirector.stopRedirection
Use afterEnter or afterUpdate to get notification changes after they happened. At this point you can use VRouter.of(context) to get any information about the new route
See also VWidgetGuard for a widget-level way of controlling navigation changes
- Inheritance
Constructors
-
VGuard({Future<
void> beforeEnter(VRedirector vRedirector) = VoidVGuard.voidBeforeEnter, Future<void> beforeUpdate(VRedirector vRedirector) = VoidVGuard.voidBeforeUpdate, Future<void> beforeLeave(VRedirector vRedirector, void saveHistoryState(Map<String, String> state)) = VoidVGuard.voidBeforeLeave, void afterEnter(BuildContext context, String? from, String to) = VoidVGuard.voidAfterEnter, void afterUpdate(BuildContext context, String? from, String to) = VoidVGuard.voidAfterUpdate, required List<VRouteElement> stackedRoutes})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- mustHaveSubRoutes → bool
-
Describes whether this VRouteElement can be a node of a VRoute
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stackedRoutes
→ List<
VRouteElement> -
See
VRouteElement.buildRoutes
final
Methods
-
afterEnter(
BuildContext context, String? from, String to) → void -
This is called after the url and the historyState are updated and this VRouteElement
was NOT in the previous route and is in the new route
You can't prevent the navigation anymore
You can get the new route parameters, and queryParameters
override
-
afterLeave(
BuildContext context, String? from, String to) → void -
This is called after the url and the historyState are updated and this VRouteElement
was in the previous route and is NOT in the new route
You can't prevent the navigation anymore
You can get the new route parameters, and queryParameters
inherited
-
afterUpdate(
BuildContext context, String? from, String to) → void -
This is called after the url and the historyState are updated and this VRouteElement
was in the previous route and is in the new route
You can't prevent the navigation anymore
You can get the new route parameters, and queryParameters
override
-
beforeEnter(
VRedirector vRedirector) → Future< void> -
This is called before the url is updated if this VRouteElement was NOT in the
previous route but is in the new route
override
-
beforeLeave(
VRedirector vRedirector, void saveHistoryState(Map< String, String> state)) → Future<void> -
Called when a url changes, before the url is updated
Use
vRedirector
if you want to redirect or stop the navigation. DO NOT use VRouter methods to redirect.vRedirector
also has information about the route you leave and the route you go tooverride -
beforeUpdate(
VRedirector vRedirector) → Future< void> -
This is called before the url is updated if this VRouteElement was in the previous
route and is in the new route
override
-
buildRoute(
VPathRequestData vPathRequestData, {required VPathMatch parentVPathMatch, required bool parentCanPop}) → VRoute? -
buildRoute
must return VRoute if it constitute (which its subroutes or not) a valid route given the input parameters VRoute should describe this valid routeinherited -
buildRoutes(
) → List< VRouteElement> - The list of possible routes Only one will be chosen to be displayed
-
getPathFromName(
String nameToMatch, {required Map< String, String> pathParameters, required GetNewParentPathResult parentPathResult, required Map<String, String> remainingPathParameters}) → GetPathFromNameResult -
This function takes a name and tries to find the path corresponding to
the route matching this name
inherited
-
getPathFromPop(
VRouteElement elementToPop, {required Map< String, String> pathParameters, required GetNewParentPathResult parentPathResult}) → VPopResult -
VPopResult.didPop
is true if this VRouteElement poppedVPopResult.extendedPath
is null if this path can't be the right one according to the path parameters VPopResult is null when this VRouteElement does not pop AND none of its stackedRoutes poppedinherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onPop(
VRedirector vRedirector) → Future< void> -
Called when a pop event occurs
A pop event can be called programmatically (with VRouter.of(context).pop())
or by other widgets such as the appBar back button
inherited
-
onSystemPop(
VRedirector vRedirector) → Future< void> -
Called when a system pop event occurs.
This happens on android when the system back button is pressed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited