remove method

void remove(
  1. String id
)

Removes one existing element. Dependants are not removed implicitly.

Implementation

void remove(String id) {
  if (!contains(id)) throw StateError('Element $id does not exist.');
  if (_inserted.remove(id) != null) {
    final placeholder = Object();
    for (final slots in [_appended, ..._before.values, ..._after.values]) {
      final index = slots.indexOf(id);
      if (index >= 0) slots[index] = placeholder;
    }
    if (_before.remove(id) case final slots?) _before[placeholder] = slots;
    if (_after.remove(id) case final slots?) _after[placeholder] = slots;
    return;
  }
  _replaced.remove(id);
  _removed.add(id);
}