示例代码
lifecycleScope.launch {
viewModel.testFlow.collect {
}
}
问题 kotlin使用StateFlow的collect出错
This is an internal kotlinx.coroutines API that should not be used from outside of kotlinx.coroutines. No compatibility guarantees are provided.It is recommended to report your use-case of internal API to kotlinx.coroutines issue tracker, so stable API could be provided instead
解决
代码中加上
import kotlinx.coroutines.flow.collect