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.
Frank van der Laan
07/04/2022, 10:27 AM
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.
*/
@MainThread
public fun clearBackStack(
route: String
): Boolean = clearBackStack(createRoute(route).hashCode())
Frank van der Laan
07/04/2022, 10:43 AM
^ even this method does nothing because the route is no longer in the backstack
i
Ian Lake
07/04/2022, 2:54 PM
clearBackStack() clears the back stack you've saved with saveState; it absolutely does work with those saved back stacks
Ian Lake
07/04/2022, 2:54 PM
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
f
Frank van der Laan
07/04/2022, 5:57 PM
aah, you are actually right. I was using the id of the screen, not the id of the graph in the tab. Thank you!