firstOrNull

suspend fun <T> Flow<T>.firstOrNull(): T?(source)

The terminal operator that returns the first element emitted by the flow and then cancels flow's collection. Returns null if the flow was empty.


suspend fun <T> Flow<T>.firstOrNull(predicate: suspend (T) -> Boolean): T?(source)

The terminal operator that returns the first element emitted by the flow matching the given predicate and then cancels flow's collection. Returns null if the flow did not contain an element matching the predicate.