forEach<T> static method

AsyncLoop forEach<T>(
  1. Iterable<T> itr,
  2. FutureOr<bool> block(
    1. T e
    )
)

Implementation

static AsyncLoop forEach<T>(
    Iterable<T> itr, FutureOr<bool> Function(T e) block) {
  if (itr is List<T>) {
    return AsyncLoop<int>(
        0, (i) => i < itr.length, (i) => i + 1, (i) => block(itr[i]));
  } else {
    var iterator = itr.iterator;
    return AsyncLoop<int>(0, (i) => iterator.moveNext(), (i) => i + 1,
        (_) => block(iterator.current));
  }
}