getFromAndToForEvent method

Map<String, DateTime> getFromAndToForEvent(
  1. EventNotificationModel eventData
)

return from and to for eventData

Implementation

Map<String, DateTime> getFromAndToForEvent(EventNotificationModel eventData) {
  DateTime? _from;
  DateTime? _to;

  if (compareAtSign(eventData.atsignCreator!,
      AtEventNotificationListener().currentAtSign!)) {
    _from = eventData.event!.startTime;
    _to = eventData.event!.endTime;
  } else {
    late AtContact currentGroupMember;
    // ignore: avoid_function_literals_in_foreach_calls
    eventData.group!.members!.forEach((groupMember) {
      // sending location to other group members
      if (compareAtSign(groupMember.atSign!,
          AtEventNotificationListener().currentAtSign!)) {
        currentGroupMember = groupMember;
      }
    });

    _from = startTimeEnumToTimeOfDay(
            currentGroupMember.tags!['shareFrom'].toString(),
            eventData.event!.startTime) ??
        eventData.event!.startTime;
    _to = endTimeEnumToTimeOfDay(
            currentGroupMember.tags!['shareTo'].toString(),
            eventData.event!.endTime) ??
        eventData.event!.endTime;
  }

  return {
    'from': _from ?? eventData.event!.startTime!,
    'to': _to ?? eventData.event!.endTime!,
  };
}