updateWhere method

void updateWhere(
  1. bool condition(
    1. T item
    ),
  2. void update(
    1. T item
    ), {
  3. int count = -1,
})

Updates items from current list, checked by condition and updated by replace.

Implementation

void updateWhere(bool Function(T item) condition, void Function(T item) update, {int count = -1}) {
  var updated = 0;
  for (var i = 0; i < length; i++) {
    if (condition(this[i])) {
      update(this[i]);
      updated++;
      if (count >= 1 && updated >= count) {
        return; // given count is valid && updated count reaches limit
      }
    }
  }
}