removeRange():-
Removes a range of elements from the list.
Removes the elements with positions greater than or equal to
start
and less thanend
, from the list. This reduces the list's length byend - start
.The provided range, given by
start
andend
, must be valid.
Example:
void main() {
List<int> numbers = [1, 2, 3, 4, 5];
print("Before removing range: $numbers");
numbers.removeRange(1, 3); // Removes elements from index 1 to 2 (inclusive)
print("After removing range: $numbers");
}
Before removing range: [1, 2, 3, 4, 5]
After removing range: [1, 4, 5]
Exited.