Reputation:
I have created a listview items with a button to add items but pressing, is there any function that I can use to remove elements on the list? for example a button next to the add button and clear the list.
Upvotes: 0
Views: 1623
Reputation: 1790
Just call method .clear(
) in variable you store list.
final list = [1, 2, 3, 4, 5];
// somewhere in your function
list.clear();
You can see many other method to remove elements in a list depends on your scenario such as
list.removeAt(index)
list.removeLast()
list.removeRange(start, end)
list.removeWhere((element) => false)
But I'm not sure about your question because it's very simple answer. Is this really what you want?
Upvotes: 1