With Navigation Compose. When I select a tab, and ...
# compose
With Navigation Compose. When I select a tab, and follow the documentation, I do this:
Copy code
popUpTo(navController.graph.findStartDestination().id) {
    saveState = true
as a result, my tab's ViewModels is not cleared when switching tabs. That's good. But let's say the user now logs out and I want to clear this ViewModel after all. How do I do so? Popping all screens from the backstack will clear all their ViewModels, but this screen is not in the backstack anymore.
Copy code
     * Clears any saved state associated with [route] that was previously saved
     * via [popBackStack] when using a `saveState` value of `true`.
     * @param route The route of the destination previously used with [popBackStack] with a
     * `saveState` value of `true`
     * @return true if the saved state of the stack associated with [route] was cleared.
    public fun clearBackStack(
        route: String
    ): Boolean = clearBackStack(createRoute(route).hashCode())
^ even this method does nothing because the route is no longer in the backstack
clearBackStack() clears the back stack you've saved with saveState; it absolutely does work with those saved back stacks
It sounds like you aren't passing in the right route? You'd want to pass in the route pattern of each tab in your bottom nav
❤️ 1
🙌 1
aah, you are actually right. I was using the id of the screen, not the id of the graph in the tab. Thank you!