问题
I have a question in my flutter dart script, this my script:
List<ReplyTile> replytile = new List<ReplyTile>();
replytile.add(
new ReplyTile(
member_photo: "photo",
member_id: "001",
date: "01-01-2018",
member_name: "Denis",
id: "001",
text: "hallo.."
)
);
My question is: how to remove items on List<ReplyTile> with id = 001.. ?
Thanks in advance
回答1:
removeWhere allows to do that:
replytile.removeWhere((item) => item.id == '001')
See also List Dartdoc
回答2:
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);
回答3:
This also works
_listofTaskUI.removeAt(_quantity);
来源:https://stackoverflow.com/questions/52778601/flutter-remove-list-item