Hi. I'm using Android Studio Chipmunk. I can't cal...
# compose
l
Hi. I'm using Android Studio Chipmunk. I can't call `viewModel()`in a `@Composable`parameter, though I've added the dependency
androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0
to build.gradle file of the app module. Why ? (I keep getting the error "Expression 'viewModel' of type 'StockfishLibraryViewModel' cannot be invoked as a function. The function 'invoke()' is not found")
This is the viewModel I'm trying to use.
i
Show your code where you are using
viewModel()
l
This is the whole file
i
You haven't imported the
viewModel()
function:
import androidx.lifecycle.viewmodel.compose.viewModel
1
👍🏾 1
l
This is the build file.
Thank you very much 🙂
i
So it thinks you are calling the
invoke()
method on your variable named
viewModel
when you add the parentheses after the variable name
The easiest way to figure that out is to rename that variable
👍 1
l
Ok, I understand better 🙂
Next time I'll start with a different name than viewModel for my parameter 🙂
202 Views