Home > Software engineering >  Koin inject viewmodel into Composable
Koin inject viewmodel into Composable

Time:03-30

I am trying to use Koin to inject my viewModel (which has some dependencies as well) like this:

Unresolved Reference

I don't understand why it cannot find getViewModel when I have the following import:

Koin import

I am using this Koin version: implementation "io.insert-koin:koin-android:$koin_version"

where $koin_version = '3.2.0-beta-1'

Any thoughts why my import is ignored here?

CodePudding user response:

You're using a wrong import, you should use:

import org.koin.androidx.compose.getViewModel

To use it you need the following dependency:

implementation("io.insert-koin:koin-androidx-compose:$koinVersion")
  • Related