Line data Source code
1 : part of '../main.dart'; 2 : 3 : class VGuard with VRouteElement, VRouteElementWithoutPage { 4 : /// This is called before the url is updated, if this [VRouteElement] is NOT in the previous route 5 : /// but IS in the new route 6 : /// 7 : /// Use [vRedirector] if you want to redirect or stop the navigation. 8 : /// DO NOT use VRouter methods to redirect. 9 : /// [vRedirector] also has information about the route you leave and the route you go to 10 : /// 11 : /// Note that you should consider the navigation cycle to 12 : /// handle this precisely, see [https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle] 13 : /// 14 : /// Also see: 15 : /// * [VRouter.beforeEnter] for global level beforeEnter 16 : /// * [VRedirector] to known how to redirect and have access to route information 17 : @override 18 : final Future<void> Function(VRedirector vRedirector) beforeEnter; 19 : 20 : /// This is called before the url is updated, if this [VRouteElement] is in the previous route 21 : /// AND in the new route 22 : /// 23 : /// Use [vRedirector] if you want to redirect or stop the navigation. 24 : /// DO NOT use VRouter methods to redirect. 25 : /// [vRedirector] also has information about the route you leave and the route you go to 26 : /// 27 : /// Note that you should consider the navigation cycle to 28 : /// handle this precisely, see [https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle] 29 : /// 30 : /// Also see: 31 : /// * [VRouter.beforeEnter] for global level beforeEnter 32 : /// * [VRedirector] to known how to redirect and have access to route information 33 : @override 34 : final Future<void> Function(VRedirector vRedirector) beforeUpdate; 35 : 36 : /// This is called before the url is updated, if this [VRouteElement] is in the previous route 37 : /// AND NOT in the new route 38 : /// 39 : /// Use [vRedirector] if you want to redirect or stop the navigation. 40 : /// DO NOT use VRouter methods to redirect. 41 : /// [vRedirector] also has information about the route you leave and the route you go to 42 : /// 43 : /// [saveHistoryState] can be used to save a history state before leaving 44 : /// This history state will be restored if the user uses the back button 45 : /// You will find the saved history state in the [VRouterData] using 46 : /// [VRouteData.of(context).historyState] 47 : /// 48 : /// Note that you should consider the navigation cycle to 49 : /// handle this precisely, see [https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle] 50 : /// 51 : /// Also see: 52 : /// * [VRouter.beforeLeave] for global level beforeLeave 53 : /// * [VNavigationGuard.beforeLeave] for widget level beforeLeave 54 : /// * [VRedirector] to known how to redirect and have access to route information 55 : @override 56 : final Future<void> Function(VRedirector vRedirector, 57 : void Function(Map<String, String> state) saveHistoryState) beforeLeave; 58 : 59 : /// This is called after the url and the state is updated if this [VRouteElement] 60 : /// was not it the previous route 61 : /// 62 : /// You can't prevent the navigation anymore 63 : /// You can get the new route parameters, and queryParameters from the context 64 : /// 65 : /// Note that you should consider the navigation cycle to 66 : /// handle this precisely, see [https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle] 67 : /// 68 : /// Also see: 69 : /// * [VRouter.afterEnter] for global level afterEnter 70 : /// * [VNavigationGuard.afterEnter] for widget level afterEnter 71 : @override 72 : final void Function(BuildContext context, String? from, String to) afterEnter; 73 : 74 : /// This is called after the url and the state is updated if this [VRouteElement] 75 : /// was already it the previous route 76 : /// 77 : /// You can't prevent the navigation anymore 78 : /// You can get the new route parameters, and queryParameters from the context 79 : /// 80 : /// Note that you should consider the navigation cycle to 81 : /// handle this precisely, see [https://vrouter.dev/guide/Advanced/Navigation%20Control/The%20Navigation%20Cycle] 82 : /// 83 : /// Also see: 84 : /// * [VRouter.afterEnter] for global level afterEnter 85 : /// * [VNavigationGuard.afterEnter] for widget level afterEnter 86 : @override 87 : final void Function(BuildContext context, String? from, String to) 88 : afterUpdate; 89 : 90 : final List<VRouteElement> stackedRoutes; 91 : 92 2 : VGuard({ 93 : this.afterEnter = VRouteElement._voidAfterEnter, 94 : this.afterUpdate = VRouteElement._voidAfterUpdate, 95 : this.beforeEnter = VRouteElement._voidBeforeEnter, 96 : this.beforeLeave = VRouteElement._voidBeforeLeave, 97 : this.beforeUpdate = VRouteElement._voidBeforeUpdate, 98 : required this.stackedRoutes, 99 : }); 100 : }