Do I have to import any specific library to retrie...
# compose
r
Do I have to import any specific library to retrieve a ViewModel into a @Composable function? I'm trying to retrieve it and the app crashes
Copy code
val viewModel: LoginViewModel by viewModel()
c
Stacktrace?
1
r
Maybe I need a ViewModel Factory
i
Your ViewModel has to actually extend
androidx.lifecycle.ViewModel
👍 1
i
As Ian said you'll need to import the lifecycle dependency for view model.
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$viewmodel_version")
r
My Viewmodel extends
androidx.lifecycle.ViewModel
😐