inline suspend fun <T> Flow<T>.collectIndexed(crossinline action: suspend (index: Int, T) -> Unit)

Terminal flow operator that collects the given flow with a provided action that takes the index of an element (zero-based) and the element. If any exception occurs during collect or in the provided flow, this exception is rethrown from this method.

See also collect and withIndex.


common source
Link copied to clipboard