julioromano
05/28/2021, 1:06 PMnavigation-compose
I’ve noticed it’s possible to navigate to a nested destination without first navigating to its nested nav graph.
Please see code in thread.julioromano
05/28/2021, 1:07 PM@Composable
fun MyApp() {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = "screenA",
) {
composable("screenA") {
ScreenA()
}
navigation(
startDestination = "screenB",
route = "nestedGraphRoute"
) {
composable("screenB") {
ScreenB()
}
composable("screenC") {
ScreenC()
}
}
}
}
It is indeed possible to navigate from “screenA” directly to “screenB” or “screenC” without first navigating to “nestedGraphRoute”.
When navigating from “screenA” directly to “screenB” the NavBackStackEntry
for “nestedGraphRoute” will be automagically pushed on the back stack.
• Is this working as intended?
• If yes, what is the usefulness of having a route
param on the nested nav graph itself? Isn’t it an implementation detail that could be hidden?Ian Lake
06/01/2021, 6:50 PM