Last time I checked graph id is not available in C...
# compose
m
Last time I checked graph id is not available in Compose Navigation in common, so we can't pop all graph properly, is it still the case?
i
Yes, it's not planned to be exposed to common. this
id
initially was about xml resource id that is simply not a case for compose and/or multiplatform. For compose navigation unique id is
route
, id for android is maintained as just hash from it.
so we can't pop all graph properly
Could you please clarify? All methods have overloads for route, int id is not required for any operation AFAIK
m
How can I clear all the routes, for now I'm doing this with a loop and popBackStack which is not efficient, Also the first route can be different and can be present multiple times on that stack, so popUntil and passing the first route to it is not going to work in a lot of cases. In voyager they have nice things such us popAll, replaceAll...
i
So how exactly int id will help you with it?
m
That's how we used to do it on Android:
popUpTo(navHostController.graph.id)
i
Why
popUpTo(navHostController.graph.route)
doesn't work for you?
m
This is the start destination right?
As I said the first route can be totally different than the start destination, for example I have SplashScreen as a start destination and I will directly pop it after few seconds. Also I have cases where the same screen can be present multiple times. A->...->A->B after popupto(A): A->...->B
i
No it's not start dest. It's set from
NavHost(route)
arg (null by default)
thank you color 1
m
Ah ok that's what I want I guess. I didn't know about it. I will check it out.
i
thank you color 1
k
Copy code
navController.navigate(NewRoot) {
  popUpTo(navController.graph.id) {
    inclusive = true
  }
}
i
@Konstantin Tskhovrebov no
id
in common. It's the topic of this thread
k
this code works in common in my project
i
Kinda. Technically we have this "id" for internal needs. It's marked as
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
and not supposed to be used externally. Not sure why IDE doesn't complain
k
a. ok. I didn't notice it 🆗
i
+ it's not in common, but in platform source set