toJson method
Implementation
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['calendarId'] = calendarId;
data['eventId'] = eventId;
data['eventTitle'] = title;
data['eventDescription'] = description;
data['eventStartDate'] = start?.millisecondsSinceEpoch ??
TZDateTime.now(local).millisecondsSinceEpoch;
data['eventStartTimeZone'] = start?.location.name;
data['eventEndDate'] = end?.millisecondsSinceEpoch ??
TZDateTime.now(local).millisecondsSinceEpoch;
data['eventEndTimeZone'] = end?.location.name;
data['eventAllDay'] = allDay;
data['eventLocation'] = location;
data['eventURL'] = url?.data?.contentText;
data['availability'] = availability.enumToString;
data['eventStatus'] = status?.enumToString;
if (attendees != null) {
data['attendees'] = attendees?.map((a) => a?.toJson()).toList();
}
if (attendees != null) {
data['organizer'] =
attendees?.firstWhereOrNull((a) => a!.isOrganiser)?.toJson();
}
if (recurrenceRule != null) {
data['recurrenceRule'] = recurrenceRule?.toJson();
}
if (reminders != null) {
data['reminders'] = reminders?.map((r) => r.toJson()).toList();
}
return data;
}