Vivek Sharma
11/13/2020, 10:30 AMProfile Composable
and other is FriendList Composable
, using as eg.
and below as onClick code
onClick = {
// This is the equivalent to popUpTo the start destination
navController.popBackStack(navController.graph.startDestination, false)
if (currentRoute != screen.route) {
navController.navigate(screen.route)
}
}
)
Lets say
So startDestination is Profile
, then we clicked on FriendList
bottom nav item, and then we clicked Profile, then FriendList
When I press back, I never go back to FriendList, though I have visited it twice
How does popBackStack works here, popping till Profile and not including ProfileCyril Find
11/13/2020, 10:44 AMpopBackStack(navController.graph.startDestination, false)
pops everything up to profile not including itCyril Find
11/13/2020, 10:45 AMCyril Find
11/13/2020, 10:47 AMnavController.navigate(screen.route) {
launchSingleTop = true
popUpTo = navController.graph.startDestination
}
so you can customize it to your use caseVivek Sharma
11/13/2020, 5:49 PMCyril Find
11/13/2020, 5:51 PMCyril Find
11/13/2020, 5:51 PM