I was using compose-navigation with bottom nav, I ...
# compose
v
I was using compose-navigation with bottom nav, I got a doubt (As docs stated one is
Profile Composable
and other is
FriendList Composable
, using as eg. and below as onClick code
Copy 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 Profile
c
yes
popBackStack(navController.graph.startDestination, false)
pops everything up to profile not including it
it does so every time you navigate so there is never a lot of back stack entries in there
btw with alpha02 there's a new syntax
Copy code
navController.navigate(screen.route) {
                        launchSingleTop = true
                        popUpTo = navController.graph.startDestination
                    }
so you can customize it to your use case
v
@Cyril Find popping upto profile and suppose I have backstack like this : Profile(start) -> Friends -> Profile -> Fragment(at top) so if you pop upto startDestination , how it will work ?
c
i think it would just pop the last Fragment but the thing is you pop eveytime you navigate
so you just have 1 Profile in your backstack