isEventTimeSlotOverlap method
dynamic
isEventTimeSlotOverlap(
- List<
EventNotificationModel?> hybridEvents, - EventNotificationModel? 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];
}