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?
Similar Posts
- Dart Program to add Single or Multiple Items to a List
- Dart program to remove duplicate items from a list
- Dart Program to update or replace List items or values
- Dart Program to remove the last element from a List
- Dart program for condition based item removal from a list
- Dart Program to generate unique id using uuid package
- Dart Program to convert a number to string