Seems if startDestination in NavHost isn't a Botto...
# compose
s
Seems if startDestination in NavHost isn't a BottomNavScreen it breaks backstack
I use this on Start and Email screens
Copy code
navController.navigate("Dashboard") {
    popUpTo("Start") {
        inclusive = true
    }
}
If I set startDestination = "Dashboard" it saves backstack per tab
s
And the solution is set "Dashboard" to startDestination and in this screen check is user logged, if not logged immediately navigate to "Email Input"?
I use Start Screen because in the docs there is "main_fragment" where checking user login status
i
And the solution is set "Dashboard" to startDestination and in this screen check is user logged, if not logged immediately navigate to "Email Input"?
That's what 'conditional navigation' means - navigating only if your conditions aren't met
s
Thanks for explanation!
c
@Sanendak this took me forever to really understand. I never understood why I wouldn't just do it the other way but over the past few years/months a lot of the nav docs has helped explain this. I think one of the best explanations is because this is a sane way to deal with deep links. Let's say a user deep links to Media List, then it can check if it has to kick a user to EmailInputScreen and if that's successful, then you just pop EmailInputScreen and BAM. Your user is right back where they wanted to be! This video which has a case study on login is really great!

https://youtu.be/09qjn706ITA?t=285

👍 1