VRouterDelegate constructor

VRouterDelegate({
  1. required List<VRouteElement> routes,
  2. Widget builder(
    1. BuildContext context,
    2. Widget child
    )?,
  3. List<NavigatorObserver> navigatorObservers = const [],
  4. Future<void> beforeEnter(
    1. VRedirector vRedirector
    ) = VoidVGuard.voidBeforeEnter,
  5. Future<void> beforeLeave(
    1. VRedirector vRedirector,
    2. void saveHistoryState(
      1. Map<String, String> historyState
      )
    ) = VoidVGuard.voidBeforeLeave,
  6. void afterEnter(
    1. BuildContext context,
    2. String? from,
    3. String to
    ) = VoidVGuard.voidAfterEnter,
  7. Future<void> onPop(
    1. VRedirector vRedirector
    ) = VoidVPopHandler.voidOnPop,
  8. Future<void> onSystemPop(
    1. VRedirector vRedirector
    ) = VoidVPopHandler.voidOnSystemPop,
  9. Widget buildTransition(
    1. Animation<double> animation,
    2. Animation<double> secondaryAnimation,
    3. Widget child
    )?,
  10. Duration? transitionDuration,
  11. Duration? reverseTransitionDuration,
  12. String initialUrl = '/',
  13. List<VLogLevel> logs = VLogs.info,
  14. GlobalKey<NavigatorState>? navigatorKey,
})

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());
  }
}