removeRange method Null safety
- @override
- int start,
- int end
Removes a range of elements from the list.
Removes the elements with positions greater than or equal to start
and less than end, from the list.
This reduces the list's length by end - start.
The provided range, given by start and end, must be valid.
A range from start to end is valid if 0 ≤ start ≤ end ≤ length.
An empty range (with end == start) is valid.
The list must be growable.
Implementation
@override
void removeRange(int start, int end) {
RangeError.checkValidRange(start, end, length, "start", "end");
// Stop listening to the element that will be replaced
for (int i = start; i < end; i++) {
E element = elementAt(i);
if (_propagateNotification &&
element != null &&
element is ChangeNotifier) {
element.removeListener(_propagate);
}
}
_values.removeRange(start, end);
notifyListeners();
}