VRouter class
This widget handles most of the routing work It gives you access to the routes attribute where you can start building your routes using VRouteElements
Note that this widget also acts as a MaterialApp so you can pass it every argument that you would expect in MaterialApp
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- VRouter
Constructors
-
VRouter({Key? key, required List<
VRouteElement> routes, Future<void> beforeEnter(VRedirector vRedirector) = VoidVGuard.voidBeforeEnter, Future<void> beforeLeave(VRedirector vRedirector, void saveHistoryState(Map<String, String> historyState)) = VoidVGuard.voidBeforeLeave, void afterEnter(BuildContext context, String? from, String to) = VoidVGuard.voidAfterEnter, Future<void> onPop(VRedirector vRedirector) = VoidVPopHandler.voidOnPop, Future<void> onSystemPop(VRedirector vRedirector) = VoidVPopHandler.voidOnSystemPop, Widget buildTransition(Animation<double> animation, Animation<double> secondaryAnimation, Widget child)?, Duration? transitionDuration, Duration? reverseTransitionDuration, VRouterMode mode = VRouterMode.hash, String initialUrl = '/', List<VLogLevel> logs = VLogs.info, Widget builder(BuildContext context, Widget child)?, @Deprecated('Please use navigatorKey instead.\n This has been removed because it is redundant with navigatorKey.') Key? appRouterKey, String title = '', GenerateAppTitle? onGenerateTitle, Color? color, ThemeData? theme, ThemeData? darkTheme, ThemeData? highContrastTheme, ThemeData? highContrastDarkTheme, ThemeMode? themeMode = ThemeMode.system, Locale? locale, Iterable<LocalizationsDelegate> ? localizationsDelegates, LocaleListResolutionCallback? localeListResolutionCallback, LocaleResolutionCallback? localeResolutionCallback, Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')], bool debugShowMaterialGrid = false, bool showPerformanceOverlay = false, bool checkerboardRasterCacheImages = false, bool checkerboardOffscreenLayers = false, bool showSemanticsDebugger = false, bool debugShowCheckedModeBanner = true, bool useInheritedMediaQuery = false, Map<LogicalKeySet, Intent> ? shortcuts, Map<Type, Action< ? actions, String? restorationScopeId, ScrollBehavior? scrollBehavior})Intent> >
Properties
-
actions
→ Map<
Type, Action< ?Intent> > -
The default map of intent keys to actions for the application.
final
- appRouterKey → Key?
-
Use this key to update the routes
final
- builder → (Widget Function(BuildContext context, Widget child)?)
-
A builder for inserting widgets above the Navigator or - when the
WidgetsApp.router constructor is used - above the Router but below the
other widgets created by the WidgetsApp widget, or for replacing the
Navigator/Router entirely.
final
-
buildTransition
→ (Widget Function(Animation<
double> animation, Animation<double> secondaryAnimation, Widget child)?) -
If implemented, this becomes the default transition for every route transition
except those who implement there own buildTransition
Also see:
final
- checkerboardOffscreenLayers → bool
-
Turns on checkerboarding of layers rendered to offscreen bitmaps.
final
- checkerboardRasterCacheImages → bool
-
Turns on checkerboarding of raster cache images.
final
- color → Color?
-
The primary color to use for the application in the operating system
interface.
final
- darkTheme → ThemeData?
-
The ThemeData to use when a 'dark mode' is requested by the system.
final
- debugShowCheckedModeBanner → bool
-
Turns on a little "DEBUG" banner in debug mode to indicate
that the app is in debug mode. This is on by default (in
debug mode), to turn it off, set the constructor argument to
false. In release mode this has no effect.
final
- debugShowMaterialGrid → bool
-
Turns on a GridPaper overlay that paints a baseline grid
Material apps.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- highContrastDarkTheme → ThemeData?
-
The ThemeData to use when a 'dark mode' and 'high contrast' is requested
by the system.
final
- highContrastTheme → ThemeData?
-
The ThemeData to use when 'high contrast' is requested by the system.
final
- initialUrl → String
-
This allows you to change the initial url
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locale → Locale?
-
The initial locale for this app's Localizations widget is based
on this value.
final
- localeListResolutionCallback → LocaleListResolutionCallback?
-
This callback is responsible for choosing the app's locale
when the app is started, and when the user changes the
device's locale.
final
- localeResolutionCallback → LocaleResolutionCallback?
-
The signature of WidgetsApp.localeResolutionCallback.
final
-
localizationsDelegates
→ Iterable<
LocalizationsDelegate> ? -
The delegates for this app's Localizations widget.
final
-
logs
→ List<
VLogLevel> -
The VRouter logs that are to be shown
final
- mode → VRouterMode
-
Two router mode are possible:
final
- mustHaveSubRoutes → bool
-
Describes whether this VRouteElement can be a node of a VRoute
no setterinherited
-
A key given to the root navigator
final
-
The list of observers for the Navigator created for this app.
final
- onGenerateTitle → GenerateAppTitle?
-
If non-null this callback function is called to produce the app's
title string, otherwise title is used.
final
- restorationScopeId → String?
-
The identifier to use for state restoration of this app.
final
- reverseTransitionDuration → Duration?
-
The reverse duration of VRouter.buildTransition
final
-
routes
→ List<
VRouteElement> -
This list holds every possible routes of your app
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollBehavior → ScrollBehavior?
-
The default ScrollBehavior for the application.
final
-
shortcuts
→ Map<
LogicalKeySet, Intent> ? -
The default map of keyboard shortcuts to intents for the application.
final
- showPerformanceOverlay → bool
-
Turns on a performance overlay.
final
- showSemanticsDebugger → bool
-
Turns on an overlay that shows the accessibility information
reported by the framework.
final
-
supportedLocales
→ Iterable<
Locale> -
The list of locales that this app has been localized for.
final
- theme → ThemeData?
-
Default visual properties, like colors fonts and shapes, for this app's
material widgets.
final
- themeMode → ThemeMode?
-
Determines which theme will be used by the application if both theme
and darkTheme are provided.
final
- title → String
-
A one-line description used by the device to identify the app for the user.
final
- transitionDuration → Duration?
-
The duration of VRouter.buildTransition
final
- useInheritedMediaQuery → bool
-
Deprecated. This setting is now ignored.
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
-
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
override
-
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
-
beforeLeave(
VRedirector vRedirector, void saveHistoryState(Map< String, String> historyState)) → 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 -
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 route
inherited
-
buildRoutes(
) → List< VRouteElement> - The list of possible routes Only one will be chosen to be displayed
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → VRouterState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
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
-
onSystemPop(
VRedirector vRedirector) → Future< void> - Called when a system pop event occurs. This happens on android when the system back button is pressed.
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → InitializedVRouterSailor