VNesterBase class

A VRouteElement which enable nesting

widgetBuilder gives you a Widget which is what you should use as the child to nest This Widget will be the one present in the VRouteElement in nestedRoutes corresponding to the current route

{@tool snippet}

If you want to nest ProfileWidget in MyScaffold at the path '/profile', here is what you can do:

VNester(
  widgetBuilder: (child) => MyScaffold(child: child),
  nestedRoutes: [
    VWidget(
      path: '/profile',
      widget: ProfileWidget(),
    ),
  ],
)

{@end-tool}

{@tool snippet}

Note that you can also use stackedRoutes if you want to nest AND stack by using nestedRoutes AND stackedRoutes:

VNester(
  path: '/home',
  widgetBuilder: (child) => MyScaffold(child: child),
  nestedRoutes: [
    VWidget(
      path: 'profile',
      alias: [':_(settings)'] // This is used because we want to display ProfileWidget while SettingsWidgets is on top of MyScaffold
      widget: ProfileWidget(),
    ),
  ],
  stackedRoutes: [
    VWidget(
      path: 'settings',
      widget: SettingsWidget(),
    ),
  ],
)

Also see:

Inheritance

Constructors

VNesterBase({required Widget widgetBuilder(Widget child), required List<VRouteElement> nestedRoutes, Duration? transitionDuration, Duration? reverseTransitionDuration, Widget buildTransition(Animation<double> animation, Animation<double> secondaryAnimation, Widget child)?, LocalKey? key, String? name, List<VRouteElement> stackedRoutes = const [], GlobalKey<NavigatorState>? navigatorKey, bool fullscreenDialog = false})
VNesterBase.builder({required Widget widgetBuilder(BuildContext context, VRouterData state, Widget child), required List<VRouteElement> nestedRoutes, Duration? transitionDuration, Duration? reverseTransitionDuration, Widget buildTransition(Animation<double> animation, Animation<double> secondaryAnimation, Widget child)?, LocalKey? key, String? name, List<VRouteElement> stackedRoutes = const [], GlobalKey<NavigatorState>? navigatorKey, dynamic fullscreenDialog = false})
Provides a state from which to access VRouter data in widgetBuilder

Properties

buildTransition Widget Function(Animation<double> animation, Animation<double> secondaryAnimation, Widget child)?
Create a custom transition effect when coming to and going to this route This has the priority over VRouter.buildTransition
final
fullscreenDialog bool
Whether this page route is a full-screen dialog.
final
hashCode int
The hash code for this object.
no setterinherited
key LocalKey?
A LocalKey that will be given to the page which contains the given widget
final
mustHaveSubRoutes bool
Describes whether this VRouteElement can be a node of a VRoute
no setterinherited
name String?
A name for the route which will allow you to easily navigate to it using VRouter.of(context).pushNamed
final
A key for the nested navigator It is created automatically
final
nestedRoutes List<VRouteElement>
A list of VRouteElement which widget will be accessible in widgetBuilder
final
reverseTransitionDuration Duration?
The reverse duration of VWidgetBase.buildTransition
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackedRoutes List<VRouteElement>
A list of routes which:
final
transitionDuration Duration?
The duration of VWidgetBase.buildTransition
final
widgetBuilder Widget Function(Widget child)
A function which creates the VRouteElement._rootVRouter associated to this VRouteElement
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
inherited
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
inherited
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
inherited
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 to
inherited
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
inherited
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 route
inherited
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 popped VPopResult.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 popped
inherited
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