removeFirstWhere method

List<T> removeFirstWhere(
  1. bool predicate(
    1. T
    ), [
  2. int count = 1
])

Remove the first count items of a list thats satisfy the predicate

Implementation

List<T> removeFirstWhere(bool Function(T) predicate, [int count = 1]) {
  if (count > 0) {
    int c = 0;
    for (int i = 0; i < length; i++) {
      if (predicate(this[i])) {
        if (c >= count) break;
        removeAt(i);
        c++;
      }
    }
  }
  return this;
}