Prateek Kumar
06/12/2024, 8:24 AMfun NavController.navigateAndClearBackstack(route: String) {
val navController = this
navController.navigate(route) {
popUpTo(navController.graph.findStartDestination().route.orEmpty()) {
inclusive = true
}
launchSingleTop = true
}
}
But it dosen’t work in all the cases , if my original startDestination is not the first element in backstack, this method won’t work.
Can anyone suggest me how to do if we do not know how my backstack looks like?youssef hachicha
06/12/2024, 12:58 PMIan Lake
06/12/2024, 1:37 PMIan Lake
06/12/2024, 1:38 PMIan Lake
06/12/2024, 1:39 PMpopUpTo(navController.graph.id)
- the graph itself is always on the back stack and is always the first entryPrateek Kumar
06/12/2024, 1:46 PM