DEV Community

Hari Pd. Chaudhary
Hari Pd. Chaudhary

Posted on

How to Push and Remove Item from List Array with Dart

To add or push item into the list array in dart:

List<String> strings = [];

strings.add("Nepal");
strings.add("India");
strings.add("United State of America");
strings.add("China");
strings.add("Canada");
Enter fullscreen mode Exit fullscreen mode

To remove item from the list array in dart:

strings.removeWhere((str){
    return str == "Nepal";
}); //go through the loop and match content to delete from list
Enter fullscreen mode Exit fullscreen mode

You can look at this Flutter example as well to learn how to add or remove element from Modal list array in Flutter App.

In this way you can add or remove item from list array in Dart and Flutter.

Discussion (0)