beforeLeave method

  1. @override
Future<void> beforeLeave(
  1. VRedirector vRedirector,
  2. void saveHistoryState(
    1. Map<String, String> state
    )
)
inherited

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

saveHistoryState can be used to save a history state before leaving This history state will be restored if the user uses the back button You will find the saved history state in the VRouteElementData using VRouter.of(context).historyState

Note that you should consider the navigation cycle to handle this precisely, see https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle

Also see:

Implementation

@override
Future<void> beforeLeave(
  VRedirector vRedirector,
  void Function(Map<String, String> state) saveHistoryState,
) =>
    voidBeforeLeave(vRedirector, saveHistoryState);