Chrome Extension

Remove List item or element using its index in Dart

If you know the index of a list element and you want to remove it from the list you can use the removeAt() method of Dart.
void main() {
  List<int> numberList = [10, 20, 30, 40, 50];
  
  numberList.removeAt(2); //Remove value from 3rd position
  print(numberList);
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

.removeAt() method dart

To pop an element from a position using its index you can use the .removeAt() method of Dart. The method will remove the element from a List and returns the removed element. The basic syntax for this method is:

List.removeAt(index);
Was this helpful?
0 Comments