onNavigation method
clients will call resolver.next(true --> default) to continue
navigation or resolver.next(false) to abort navigation
example
Implementation
@override
Future<void> onNavigation(
final NavigationResolver resolver,
final StackRouter router,
) async {
final AuthenticationBloc auth = context.authBloc(listen: false);
if (auth.state is AuthInitial) {
await router.push(initialScreenRoute);
final AuthenticationState newState = await auth.stream.first;
if (newState is AuthError) {
await router.replace(
errorRoute.call(
newState.error,
),
);
throw Exception(
newState.error,
);
}
router.removeLast();
await _handleAuthStatus(
auth,
router,
authRoute,
resolver,
removeRoutesPredicateOnAuth,
);
} else {
await _handleAuthStatus(
auth,
router,
authRoute,
resolver,
removeRoutesPredicateOnAuth,
);
}
}