Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/remove where #53

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/src/event_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class EventController<T> extends ChangeNotifier {
}
}

/// Removes multiple [event] from this controller.
void removeWhere(bool Function(CalendarEventData<T> element) test) {
for (final e in _events) {
e.removeWhere((element) => test(element));
}
PRBaraiya marked this conversation as resolved.
Show resolved Hide resolved
notifyListeners();
}

void _addEvent(CalendarEventData<T> event) {
assert(event.endDate.difference(event.date).inDays >= 0,
'The end date must be greater or equal to the start date');
Expand Down Expand Up @@ -195,6 +203,12 @@ class _YearEvent<T> {
}
return false;
}

void removeWhere(bool Function(CalendarEventData<T> element) test) {
for (final e in _months) {
e.removeWhere((element) => test(element));
}
}
}

class _MonthEvent<T> {
Expand Down Expand Up @@ -229,4 +243,8 @@ class _MonthEvent<T> {
return true;
}
}

void removeWhere(bool Function(CalendarEventData<T> element) test) {
_events.removeWhere((element) => test(element));
}
}