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.
Sourcepub fn composing_entry(&self) -> Option<NavBackStackEntry<R>>
pub fn composing_entry(&self) -> Option<NavBackStackEntry<R>>
The entry whose screen or dialog composes the caller, when this
controller’s host shows it — the NavBackStackEntry that Android’s
NavHost gives each destination. Call it while composing. It does not
subscribe the caller, and it is None once the entry is popped.
Sourcepub fn previous_back_stack_entry(&self) -> Option<NavBackStackEntry<R>>
pub fn previous_back_stack_entry(&self) -> Option<NavBackStackEntry<R>>
The entry beneath the top one, which a pop shows — Android’s
previousBackStackEntry. It does not subscribe the caller.
Sourcepub fn back_stack_entry(&self, route: &R) -> Option<NavBackStackEntry<R>>
pub fn back_stack_entry(&self, route: &R) -> Option<NavBackStackEntry<R>>
The topmost entry of route — Android’s getBackStackEntry(route).
It does not subscribe the caller.