consumeAsFlow

Represents the given stream as a flow and closes the stream afterwards. The resulting flow can be collected only once and throws IllegalStateException when trying to collect it more than once.