clear method Null safety

void clear(
  1. {bool notifyChanges = true}
)

Removes all objects from this list; the length of the list becomes zero.

The list must be growable.

final numbers = <int>[1, 2, 3];
numbers.clear();
print(numbers.length); // 0
print(numbers); // []

Implementation

void clear({bool notifyChanges = true}) {
  final stateChangedEvent =
      EmpireStateChanged.clearedList(_value, propertyName: propertyName);
  _value.clear();

  if (notifyChanges) {
    _viewModel.notifyChanges([stateChangedEvent]);
  }
}