dart

Dart Program to remove multiple items from a List at once

If you want to delete multiple elements from a list with one line of code then you can use the .removeRange() method of Dart.

void main() {
    List<int> numberList = [10, 20, 30, 40, 50];

    numberList.removeRange(0, 3);
    print(numberList); // -> prints [40, 50]
}
Output
[40, 50]

removeRange() method Dart

To remove more than one item from a List in Dart, the .removeRange() method can be used. The basic syntax is:

List.removeRange(int startIndex, int endIndex)
Was this helpful?