i am struggling to use hilt with navigation-compos...
# compose
z
i am struggling to use hilt with navigation-compose library. can anyone suggest any documentation or sample? actually i didn't found any documentation.
z
Considering you get the NavBackStackEntry as an argument of the composable { route (and it gets set as the local ViewModelStoreOwner) , it should be as simple as injecting the HiltViewModelFactory into the Activity, and then using
=
viewModel(
hiltviewmodelfactory)
Or at least I think that should theoretically work
z
@zhuinden from which package i can get
hiltviewmodelfactory
z
seems to be
dagger.hilt.android.lifecycle.HiltViewModelFactory
z
I found this
viewModel(HiltViewModelFactory(AmbientContext.current, backStackEntry))
from release note. But unable to find any ``HiltViewModelFactory` that takes
backStackEntry
as constructor parameter.
i
Sounds like you've imported the wrong
HiltViewModelFactory
- don't import the
internal
one
z
then I am going to wait for the next week. lazy me 😬