isEventTimeSlotOverlap method
dynamic
isEventTimeSlotOverlap(
- List<
EventNotificationModel?> hybridEvents, - EventNotificationModel? newEvent
checks if there is any overlap in time slots between the provided hybridEvents
and newEvent
Implementation
dynamic isEventTimeSlotOverlap(List<EventNotificationModel?> hybridEvents,
EventNotificationModel? newEvent) {
var isOverlap = false;
EventNotificationModel? overlapEvent = EventNotificationModel();
for (var element in hybridEvents) {
if (!element!.event!.isRecurring!) {
if (dateToString(element.event!.date!) ==
dateToString(newEvent!.event!.date!)) {
var event = element.event!;
if (event.startTime!.hour >= newEvent.event!.startTime!.hour &&
event.startTime!.hour <= newEvent.event!.endTime!.hour) {
isOverlap = true;
overlapEvent = element;
return [isOverlap, overlapEvent];
}
if (event.startTime!.hour <= newEvent.event!.startTime!.hour &&
event.endTime!.hour >= newEvent.event!.endTime!.hour) {
isOverlap = true;
overlapEvent = element;
return [isOverlap, overlapEvent];
}
if (event.endTime!.hour >= newEvent.event!.startTime!.hour &&
event.endTime!.hour <= newEvent.event!.endTime!.hour) {
isOverlap = true;
overlapEvent = element;
}
}
}
}
return [isOverlap, overlapEvent];
}