forEach<T> method Null safety

Future<void> forEach<T>(
  1. Stream<T> stream,
  2. FutureOr<State> onData(
    1. T
    )
)

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.

Implementation

Future<void> forEach<T>(
  Stream<T> stream,
  FutureOr<State> Function(T) onData,
);