forEach<T> abstract method
Future<void>
forEach<T>(
- Stream<
T> stream, { - required State onData(
- T data
- State onError(
- Object error,
- StackTrace stackTrace
Subscribes to the provided stream and invokes the onData callback
when the stream emits new data and the result of onData is emitted.
forEach completes when the event handler is cancelled or when
the provided stream has ended.
If onError is omitted, any errors on this stream
are considered unhandled, and will be thrown by forEach.
As a result, the internal subscription to the stream will be canceled.
If onError is provided, any errors on this stream will be passed on to
onError and will not result in unhandled exceptions or cancelations to
the internal stream subscription.
Note: The stack trace argument may be StackTrace.empty
if the stream received an error without a stack trace.
Implementation
Future<void> forEach<T>(
Stream<T> stream, {
required State Function(T data) onData,
State Function(Object error, StackTrace stackTrace)? onError,
});