mgrazianodecastro
03/06/2023, 2:41 PMstack: [A, B, C] -> [A, B, D]
curioustechizen
03/06/2023, 2:45 PMpopUpTo
for this. Something like
navController.navigate("D") {
popUpTo("C") { inclusive = true }
}
Not sure if there's a more idiomatic way.curioustechizen
03/06/2023, 2:46 PMreplaceWith(route: String)
that pops up to the current route.mgrazianodecastro
03/06/2023, 2:47 PMIan Lake
03/06/2023, 3:15 PMStylianos Gakis
03/06/2023, 8:40 PMpopUpTo(B)
cause it’s the first thing that comes to mind when I want to achieve this.Ian Lake
03/06/2023, 8:43 PMpopUpTo(B)
and popUpTo(C) { inclusive = true }
would indeed always be the sameIan Lake
03/06/2023, 8:47 PMA -> B -> Y -> C
If you popUpTo(B)
, then you are also going to pop Y
off the back stack and destroy its state, giving you a brand new copy that gets auto-inserted when you navigate to D
(since D
is part of Y's graph):
A -> B -> Y' -> D
But if you popUpTo(C) { inclusive = true }
, then Y
will not be popped and will keep its state:
A -> B -> Y -> D
Ian Lake
03/06/2023, 8:49 PMB
in any case - you'd use popUpTo(Y) { inclusive = true }
to pop the entire graph off the back stack no matter if you are on C or D, for instanceIan Lake
03/06/2023, 8:50 PMinclusive
flag is there - because sometimes it makes more sense to say what you are popping up to but leaving behind and sometimes it makes more sense to say what exactly you are removingStylianos Gakis
03/06/2023, 8:54 PMmgrazianodecastro
03/07/2023, 2:34 PM