replace method

bool replace(
  1. T existing,
  2. T replacement
)

Replaces the first occurrence of value in this list.

Runtime is O(n).

Implementation

bool replace(T existing, T replacement) {
  final index = _rawList.indexOf(existing);
  if (index == -1) return false;
  _rawList = _rawList.toList();
  _rawList.removeAt(index);
  _rawList.insert(index, replacement);
  _listChanged();
  return true;
}