Tin Tran
08/05/2021, 10:46 AMTin Tran
08/05/2021, 10:49 AMTin Tran
08/05/2021, 10:49 AMhiltViewModel(navController.getBackStackEntry("b")
Tin Tran
08/05/2021, 10:50 AMnestedB
got this error
java.lang.IllegalArgumentException: No destination with route b is on the NavController's back stack. The current destination is Destination(0xe5901274) route=a
Tin Tran
08/05/2021, 10:59 AMIan Lake
08/05/2021, 1:36 PMIan Lake
08/05/2021, 1:36 PMgetBackStackEntry()
in a remember
?Tin Tran
08/05/2021, 1:38 PMTin Tran
08/05/2021, 1:45 PMnavigation(startDestination = "nestedB", route = "b") {
composable(route = "nestedB") {
val backStackEntry = remember {navController.getBackStackEntry("b")}
ComposableB(navController = navController, hiltViewModel(backStackEntry))
}
composable(route = "nestedC") {
val backStackEntry = remember {navController.getBackStackEntry("b")}
ComposableC(navController = navController, hiltViewModel(backStackEntry))
}
}
Tin Tran
08/05/2021, 1:45 PMjava.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels until it is added to the NavController's back stack (i.e., the Lifecycle of the NavBackStackEntry reaches the CREATED state).
Ian Lake
08/05/2021, 2:08 PMIan Lake
08/05/2021, 2:09 PMTin Tran
08/05/2021, 2:12 PM