sindrenm
01/08/2024, 12:05 PMhiltViewModel()
from androidx.hilt:hilt-navigation-compose is supposed to provide the same SavedStateHandle
to the ViewModel
that the NavBackStackEntry
gets? That would make sense to me, at least, but it's not what I'm seeing:
composable("route") { bse ->
bse.savedStateHandle.set("some-key", "some-value")
val viewModel: ScreenViewModel = hiltViewModel()
}
@HiltViewModel
internal class ScreenViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
) : ViewModel() {
init {
println(savedStateHandle["some-key"]) // prints null
}
}
Ian Lake
01/08/2024, 3:08 PMsindrenm
01/08/2024, 5:42 PM