如何在 Kotlin 中将 Flow<List<T>> 转换为 Flow<T>?

How to transform Flow<List<T>> to Flow<T> in Kotlin?

我得到了 Flow<List<T>> 类型的流,我需要从中得到 Flow<T> 类型的流。

我试过了:

outerFlow.onEach { items -> items.onEach { flow { emit(it) } }

这不起作用。我怎样才能做到这一点?

参见 docs flatMapConcat:

outerFlow.flatMapConcat { it.asFlow() }