onErrorReturn method Null safety
- T returnValue
instructs a Stream to emit a particular item when it encounters an error, and then terminate normally
The onErrorReturn operator intercepts an onError notification from the source Stream. Instead of passing it through to any observers, it replaces it with a given item, and then terminates normally.
If you need to perform logic based on the type of error that was emitted,
please consider using
ErrorStream(Exception()) .onErrorReturn(1) .listen(print); // prints 1
Stream<T> onErrorReturn(T returnValue) => transform( OnErrorResumeStreamTransformer<T>((_, __) => Stream.value(returnValue)));