The removeRange()
method removes the items within the specified range in the list.
List_name.removeRange(int start, int end);
Start
: This specifies the starting position for removing the items in the list.
End
: This specifies the position in the list to stop removing the items in the list.
The return type of the removeRange()
method is void
.
The following code shows how to use the removeRange()
method in Dart:
void main() {// Creating listvar myList = [3, 6, 'Avogados', 'Bag', 'Apple', 'four', 'five'];// display listprint('The list before removing the list element ${myList}');// remove items from index 2 to 4// using removeRange()myList.removeRange(2, 5);// display listprint('The new list after removing the list elements: ${myList}');}
List
.List
.List
.