StateFlow and MutableStateFlow are not available in Kotlin multiplatform common code:
import kotlinx.coroutines.flow.StateFlow
Unresolved reference: StateFlow
Are these only available to platform-specific code? It seems to work fine in e.g. android code
Gradle:
sourceSets {
def coroutines_version = "1.3.7"
commonMain {
dependencies {
implementation(kotlin('stdlib-common'))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
// ...
}
}
// ...
}
You should add a dependency on "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version" artifact. Does it help?
Oh... that does help, thank you!
You should add a dependency on "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version" artifact. Does it help?
Just a note for anyone reading this that is using Kotlin 1.4+ -- this is no longer correct. The commonMain dependency is now simply org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version. See https://kotlinlang.org/docs/reference/migrating-multiplatform-project-to-14.html.
Most helpful comment
Just a note for anyone reading this that is using Kotlin 1.4+ -- this is no longer correct. The
commonMaindependency is now simplyorg.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version. See https://kotlinlang.org/docs/reference/migrating-multiplatform-project-to-14.html.