Search code snippets, questions, articles...

Dart Program to remove the last element from a List

To remove the last item or element from a list using Dart - you can use the .removeLast() method.
void main() {
  List<int> numberList = [1, 2, 3, 4, 5];
  
  numberList.removeLast();
  print(numberList);
}

.removeLast() method in Dart

The above code will pop the last element from the list.

Was this helpful?
0 Comments