我想从ListView.builder
的列表中删除一项,但这是只读的。
List<Map> entries = [{'date': '2019-08-10', 'data': 85.0}, {'date': '2019-08-14', 'data': 84.0}];
onPressed: () {
removeItem(index);
}
void removeItem(index) {
entries.removeAt(index);
}
Another exception was thrown: Unsupported operation: read-only
这也不起作用:
onPressed: () {
removeItem(date);
}
void removeItem(date) {
entries.removeWhere((item) => item['date'] == date);
}