CalendarEvent.fromJson constructor
Creates a new instance of CalendarEvent
from a JSON object.
The JSON object should contain keys that correspond to the parameters of [CalendarEvent]
.
The 'start
' and 'end' keys should map to JSON objects with a 'dateTime' key.
The 'attendees' key should map to a list of JSON objects that can be converted to [Attendee]
objects.
The 'organizer' key should map to a JSON object that can be converted to an [Organizer]
object.
Implementation
factory CalendarEvent.fromJson(Map<String, dynamic> json) {
return CalendarEvent(
id: json['id'],
createdDateTime: json['createdDateTime'],
lastModifiedDateTime: json['lastModifiedDateTime'],
isReminderOn: json['isReminderOn'],
subject: json['subject'],
bodyPreview: json['bodyPreview'],
isAllDay: json['isAllDay'],
isOrganizer: json['isOrganizer'],
startDateTime: json['start'] != null ? json['start']['dateTime'] : null,
endDateTime: json['end'] != null ? json['end']['dateTime'] : null,
attendees: json['attendees'] != null
? (json['attendees'] as List)
.map((attendee) => Attendee.fromJson(attendee))
.toList()
: null,
organizer: json['organizer'] != null
? Organizer.fromJson(json['organizer'])
: null,
);
}