showConcurrentEventDialog method

bool? showConcurrentEventDialog(
  1. List<EventNotificationModel>? createdEvents,
  2. EventNotificationModel? newEvent,
  3. BuildContext context
)

checks if newEvent overlaps with any other event

Implementation

bool? showConcurrentEventDialog(List<EventNotificationModel>? createdEvents,
    EventNotificationModel? newEvent, BuildContext context) {
  try {
    // ignore: prefer_is_empty
    if (!isEventUpdate && createdEvents != null && createdEvents.length > 0) {
      var isOverlapData =
          isEventTimeSlotOverlap(createdEvents, eventNotificationModel);
      if (isOverlapData[0]) {
        showDialog<void>(
            context: context,
            barrierDismissible: true,
            builder: (BuildContext context) {
              return ConcurrentEventRequest(
                  concurrentEvent: isOverlapData[1]);
            });

        return isOverlapData[0];
      } else {
        return isOverlapData[0];
      }
    } else {
      return false;
    }
  } catch (e) {
    _logger.severe('Error in showConcurrentEventDialog $e');
    return false;
  }
}