removeRange method
Removes a range of elements from the slice and the underlying list.
Removes the elements with positions greater than or equal to start
and less than end
,
from the slice and underlying list. This reduces the slice and underlying 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.
Note, the ranges of other slices on the underlying list will not change, therefore use with care as this may shift the underlying data in other slices.
Implementation
@override
void removeRange(int start, int end) {
final (normalizedStart, normalizedEnd) =
_validateAndNormalizeRange(start, end);
_list.removeRange(normalizedStart, normalizedEnd);
_end -= normalizedEnd - normalizedStart;
}