0

i have an object _events with datatype Map<DateTime, List>. it stores list of events of a particular date. for now i am not aware how to remove a particular event from _events

 Map<DateTime, List> _events;
  • `_events[someDate].removeMethod(...)` - where `removeMetod` is one of: `remove, removeAt, removeLast, removeRange, removeWhere` – pskink Nov 18 '20 at 07:00

1 Answers1

0

Use removeWhere()

Remove based on Date

_events.removeWhere((key, value) => key == myDateObject);

Remove based on Event List

_events.removeWhere((key, value) => value == eventList);

In the second case, do remeber it will apply default list comparision which means both lists should have same objects in the same order. If you want you can provide your custom list comparisions. Check this

Sisir
  • 4,584
  • 4
  • 26
  • 37