Dart Iterable  removeRange()

Dart Iterable removeRange()

·

1 min read

removeRange():-

  • 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.

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.