Marcin Mazurek
07/09/2021, 8:06 AMMarcin Mazurek
07/09/2021, 8:07 AMval mutableState = remember { mutableStateOf(1) }
BottomNavigationItem(
...
onClick = {
state.value = state.value + 1
navController.navigate("home") {
popUpTo(navController.graph.startDestinationRoute!!) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
and one navigation destination
fun NavGraphBuilder.HomeFeature(mutableState: MutableState<Int>){
composableCommand(NavigationDirections.home) {
Text(text = "HomeLayout ${mutableState.value}")
}
}
Ian Lake
07/09/2021, 7:33 PMrememberSaveable
) or by storing it in a ViewModel, it will already be there when you navigate to that destination with the code you have written. That would also means that it would be cleaned up correctly when you pop that destination off the back stack (which would not be the case for a hoisted remember
variable)Marcin Mazurek
07/12/2021, 3:54 PM