pairwise property

Stream<(T, T)> get pairwise

Pairs each event with the previous one as (previous, current). Skips the first event (no previous exists).

Implementation

Stream<(T, T)> get pairwise async* {
  T? prev;
  await for (final value in this) {
    if (prev != null) yield (prev, value);
    prev = value;
  }
}