timeoutOrNull

fun <T> ERROR CLASS: Symbol not found for Flow<T>.timeoutOrNull(timeout: ERROR CLASS: Symbol not found for Duration): ERROR CLASS: Symbol not found for Flow<T?>(source)

Emits the first value from the upstream flow or null if no value is emitted within the given timeout.

Timeout must be positive.

Example:

val result = flow {
delay(2.seconds)
emit("Hello")
}
.timeoutOrNull(1.seconds)
.first()

println(result)

Result will be null