How to remove items on List<ReplyTile>
with id = 001
.. ?
final List<ReplyTile> _replytile = <ReplyTile>[]; _replytile.add( ReplyTile( member_photo: 'photo', member_id: '001', date: '01-01-2018', member_name: 'Denis', id: '001', text: 'hallo..' ) );
How to Remove an Element from a List Using the remove() Method in Python. To remove an element from a list using the remove() method, specify the value of that element and pass it as an argument to the method. remove() will search the list to find it and remove it.
You can use the pop() method to remove specific elements of a list. pop() method takes the index value as a parameter and removes the element at the specified index. Therefore, a[2] contains 3 and pop() removes and returns the same as output. You can also use negative index values.
removeWhere
allows to do that:
replytile.removeWhere((item) => item.id == '001')
See also List Dartdoc
In your case this works:
replytile.removeWhere((item) => item.id == '001');
For list with specific datatype such as int, remove also works.Eg:
List id = [1,2,3]; id.remove(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With