Rahul Sainani
04/07/2021, 2:18 PMpopUpTo(Route.initial) { inclusive = true }
doesn't seem to work and all the routes after initial are still present.
Is there a way to make sure we clear the back stack without knowing about the first route in the graph?julioromano
04/07/2021, 2:25 PMnavController.navigate("home") {
popUpTo(navController.backStack.first.destination.id) { inclusive = true }
}
Not sure if it’s the best way: @Ian Lake , if available, might want to chime in 🙂 on this one.Rahul Sainani
04/07/2021, 2:37 PMbackStack
on NavController
is restricted to library, maybe there is indeed another way.Ian Lake
04/07/2021, 2:46 PMIan Lake
04/07/2021, 2:46 PMnavController.graph.id
julioromano
04/07/2021, 3:01 PMnavController.graph.id
looks much better.
Is navController.graph.id
always equal to the id of the NavHost
’s startDestination
?
I’ve RTFM:
/**
* NavGraph is a collection of {@link NavDestination} nodes fetchable by ID.
*
* <p>A NavGraph serves as a 'virtual' destination: while the NavGraph itself will not appear
* on the back stack, navigating to the NavGraph will cause the
* {@link #getStartDestination starting destination} to be added to the back stack.</p>
*/
Seems it’s a “yes” :)Rahul Sainani
04/07/2021, 3:10 PMIan Lake
04/07/2021, 4:18 PMIan Lake
04/07/2021, 4:28 PM