Skip to content

Instantly share code, notes, and snippets.

@leocavalcante
Created February 24, 2020 16:04
Show Gist options
  • Save leocavalcante/3138a37b6ece69b99a05b69187db7433 to your computer and use it in GitHub Desktop.
Save leocavalcante/3138a37b6ece69b99a05b69187db7433 to your computer and use it in GitHub Desktop.
class Event {
int idColumn;
int idSchedule;
Event(this.idColumn, this.idSchedule);
String toString() => 'Col $idColumn - Sched $idSchedule';
}
class Exclusion {
String date;
int idSchedule;
Exclusion(this.date, this.idSchedule);
}
void main() {
final _events = <DateTime, List<dynamic>>{
DateTime.parse("2010-10-10"): [Event(1, 2), Event(3, 4)],
DateTime.parse("2011-10-10"): [Event(5, 6), Event(7, 8)],
DateTime.parse("2012-10-10"): [Event(9, 10), Event(11, 12)],
};
final _listExclusions = [
Exclusion("2011-10-10", 7),
];
_listExclusions.asMap().forEach((i, _) {
if (_events[DateTime.parse(_listExclusions[i].date)] != null) {
print(_events[DateTime.parse(_listExclusions[i].date)]);
_events[DateTime.parse(_listExclusions[i].date)].removeWhere(
(item) => item.idColumn == _listExclusions[i].idSchedule
);
}
});
print(_events);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment