toJson method
Converts this CalendarEvent
object to a JSON object.
Each parameter of CalendarEvent corresponds to a key in the resulting JSON object.
The start
and 'end' keys map to JSON objects with a dateTime
key.
The attendees key maps to a list of JSON objects obtained from the Attendee objects.
If the list of attendees is null
, the attendees key maps to null
.
The organizer key maps to a JSON object obtained from the Organizer object.
If the Organizer object is null
, the organizer key maps to null
.
Implementation
Map<String, dynamic> toJson() {
return {
'id': id,
'createdDateTime': createdDateTime,
'lastModifiedDateTime': lastModifiedDateTime,
'isReminderOn': isReminderOn,
'subject': subject,
'bodyPreview': bodyPreview,
'isAllDay': isAllDay,
'isOrganizer': isOrganizer,
'start': startDateTime != null ? {'dateTime': startDateTime} : null,
'end': endDateTime != null ? {'dateTime': endDateTime} : null,
'attendees': attendees?.map((attendee) => attendee.toJson()).toList(),
'organizer': organizer?.toJson(),
};
}