VRouterDelegate constructor
VRouterDelegate({
- required List<
VRouteElement> routes, - Widget builder(
- BuildContext context,
- Widget child
- Future<
void> beforeEnter(- VRedirector vRedirector
- Future<
void> beforeLeave(- VRedirector vRedirector,
- void saveHistoryState()
- void afterEnter(
- BuildContext context,
- String? from,
- String to
- Future<
void> onPop(- VRedirector vRedirector
- Future<
void> onSystemPop(- VRedirector vRedirector
- Widget buildTransition()?,
- Duration? transitionDuration,
- Duration? reverseTransitionDuration,
- String initialUrl = '/',
- List<
VLogLevel> logs = VLogs.info,
Implementation
VRouterDelegate({
required this.routes,
this.builder,
this.navigatorObservers = const [],
Future<void> Function(VRedirector vRedirector) beforeEnter =
VoidVGuard.voidBeforeEnter,
Future<void> Function(
VRedirector vRedirector,
void Function(Map<String, String> historyState) saveHistoryState,
)
beforeLeave = VoidVGuard.voidBeforeLeave,
void Function(BuildContext context, String? from, String to) afterEnter =
VoidVGuard.voidAfterEnter,
Future<void> Function(VRedirector vRedirector) onPop =
VoidVPopHandler.voidOnPop,
Future<void> Function(VRedirector vRedirector) onSystemPop =
VoidVPopHandler.voidOnSystemPop,
this.buildTransition,
this.transitionDuration,
this.reverseTransitionDuration,
this.initialUrl = '/',
this.logs = VLogs.info,
GlobalKey<NavigatorState>? navigatorKey,
}) : navigatorKey = navigatorKey ?? GlobalKey<NavigatorState>(),
_rootVRouter = RootVRouter(
routes: routes,
afterEnter: afterEnter,
beforeEnter: beforeEnter,
beforeLeave: beforeLeave,
onPop: onPop,
onSystemPop: onSystemPop,
) {
// Set the logs to the desired ones
VLogPrinter.showLevels = logs;
// If we are on the web, we listen to any unload event.
// This allows us to call beforeLeave when the browser or the tab
// is being closed for example
if (Platform.isWeb) {
BrowserHelpers.onBrowserBeforeUnload.listen((e) => _onBeforeUnload());
}
}