pub struct NavController<R: Clone + 'static> { /* private fields */ }Expand description
The back stack of a NavHost — Android’s
NavController.
It is Copy, so it moves into any number of move closures:
move || nav.navigate(Screen::Detail { id }). R is the route type,
usually an enum whose variants carry the screen’s arguments.
Implementations§
Pushes route on top of the back stack — Android’s navigate(route).
Navigates to route the way options say — Android’s
navigate(route) { popUpTo(...); launchSingleTop = true }.
Sourcepub fn pop_back_stack(&self) -> bool
pub fn pop_back_stack(&self) -> bool
Pops the top entry and returns whether there was one — Android’s
popBackStack(). Popping the last entry leaves the host empty.
Sourcepub fn pop_back_stack_to(&self, route: &R, inclusive: bool) -> bool
pub fn pop_back_stack_to(&self, route: &R, inclusive: bool) -> bool
Pops the entries above the topmost route, and that entry too when
inclusive, and returns whether anything was popped — Android’s
popBackStack(route, inclusive).
Pops the top entry when there is one beneath it, and returns whether it
did — Android’s navigateUp().
Sourcepub fn current_route(&self) -> Option<R>
pub fn current_route(&self) -> Option<R>
The route on top of the back stack, None once everything is popped.
Reading it in a composable recomposes that composable when it changes —
Android’s currentBackStackEntryAsState().
Sourcepub fn back_stack(&self) -> Vec<R>
pub fn back_stack(&self) -> Vec<R>
Every route on the back stack, bottom first. Reading it in a
composable recomposes that composable when it changes — Android’s
currentBackStack.