addStream<T> method
VoidCallback
addStream<T>(
- Stream<
T> stream, { - DataCallback<
T> ? onData, - DoneCallback? onDone,
- ErrorCallback? onError,
- bool cancelOnError = false,
Implementation
VoidCallback addStream<T>(Stream<T> stream,
{DataCallback<T>? onData,
DoneCallback? onDone,
ErrorCallback? onError,
bool cancelOnError = false}) =>
addSubscription((removeSubscription) => stream
.listen(
onData,
onDone: onDone == null
? removeSubscription
: () {
removeSubscription();
onDone();
},
onError: cancelOnError
? onError == null
? (Object error, StackTrace stackTrace) {
removeSubscription();
Error.throwWithStackTrace(error, stackTrace);
}
: (Object error, StackTrace stackTrace) {
removeSubscription();
onError(error, stackTrace);
}
: onError,
)
.cancel);