Do we have a way to inject parameters from arguments inside viewmodel from compose navigation with hilt?
For example, I have parameter, that I pass and I have
Copy code
val viewmodel: ViewModel = hiltViewModel()
How do I pass a parameter from arguments to constructor?
j
JulianK
09/23/2021, 2:50 PM
You don't pass arguments to the hiltViewModel() function, instead, inject an instance of SavedStateHandle into your viewModel: https://developer.android.com/jetpack/compose/libraries#hilt
You can than get your navigation arguments from there.