firstOrDefault

suspend fun <T> Flow<T>.firstOrDefault(default: T): T

Returns the first value of the flow, or default if the flow completes without emitting.

The upstream is cancelled after the first value. A null first value is returned as is when T is nullable; default is used only for an empty flow.