replace method

bool replace(
  1. T item,
  2. Predicate<T> test, [
  3. bool notify = true
])

Replaces first item in List for given test

Implementation

bool replace(T item, Predicate<T> test, [bool notify = true]) {
  final index = _list.indexWhere(test);

  final replace = index >= 0;

  if (replace) {
    _list.removeAt(index);
    _list.insert(index, item);

    if (notify) {
      this.notify();
    }
  }

  return replace;
}