setError method Null safety

void setError (
  1. Object error,
  2. [StackTrace? stackTrace]
)

Completes this to a stream that emits error and then closes.

This is useful when the process of creating the data for the stream fails.

Any one of setSourceStream, setEmpty, and setError may be called at most once. Trying to call any of them again will fail.

Implementation

void setError(Object error, [StackTrace? stackTrace]) {
  setSourceStream(Stream.fromFuture(Future.error(error, stackTrace)));
}