remove method

  1. @override
bool remove(
  1. Object element
)
override

Removes the first occurrence of value from this list.

Returns true if value was in the list, false otherwise.

var parts = ['head', 'shoulders', 'knees', 'toes'];
parts.remove('head'); // true
parts.join(', ');     // 'shoulders, knees, toes'

The method has no effect if value was not in the list.

// Note: 'head' has already been removed.
parts.remove('head'); // false
parts.join(', ');     // 'shoulders, knees, toes'

The list must be growable.

Implementation

@override
bool remove(Object element) {
  if (lock) return super.remove(element);

  final index = super.indexOf(element);
  if (index != -1) {
    lock = true;
    added = const {};
    removed = {index: super[index]};
    changed = const {};
    super.remove(element);
    notifyListeners();
    return true;
  }
  return false;
}