fromJson static method
Returns a new SpatioEvent instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SpatioEvent? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'id'), 'Required key "SpatioEvent[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "SpatioEvent[id]" has a null value in JSON.');
assert(json.containsKey(r'title'), 'Required key "SpatioEvent[title]" is missing from JSON.');
assert(json[r'title'] != null, 'Required key "SpatioEvent[title]" has a null value in JSON.');
assert(json.containsKey(r'start_time'), 'Required key "SpatioEvent[start_time]" is missing from JSON.');
assert(json[r'start_time'] != null, 'Required key "SpatioEvent[start_time]" has a null value in JSON.');
assert(json.containsKey(r'end_time'), 'Required key "SpatioEvent[end_time]" is missing from JSON.');
assert(json[r'end_time'] != null, 'Required key "SpatioEvent[end_time]" has a null value in JSON.');
assert(json.containsKey(r'all_day'), 'Required key "SpatioEvent[all_day]" is missing from JSON.');
assert(json[r'all_day'] != null, 'Required key "SpatioEvent[all_day]" has a null value in JSON.');
assert(json.containsKey(r'status'), 'Required key "SpatioEvent[status]" is missing from JSON.');
assert(json[r'status'] != null, 'Required key "SpatioEvent[status]" has a null value in JSON.');
assert(json.containsKey(r'visibility'), 'Required key "SpatioEvent[visibility]" is missing from JSON.');
assert(json[r'visibility'] != null, 'Required key "SpatioEvent[visibility]" has a null value in JSON.');
assert(json.containsKey(r'busy'), 'Required key "SpatioEvent[busy]" is missing from JSON.');
assert(json[r'busy'] != null, 'Required key "SpatioEvent[busy]" has a null value in JSON.');
assert(json.containsKey(r'account_id'), 'Required key "SpatioEvent[account_id]" is missing from JSON.');
assert(json[r'account_id'] != null, 'Required key "SpatioEvent[account_id]" has a null value in JSON.');
assert(json.containsKey(r'provider_id'), 'Required key "SpatioEvent[provider_id]" is missing from JSON.');
assert(json[r'provider_id'] != null, 'Required key "SpatioEvent[provider_id]" has a null value in JSON.');
assert(json.containsKey(r'created_at'), 'Required key "SpatioEvent[created_at]" is missing from JSON.');
assert(json[r'created_at'] != null, 'Required key "SpatioEvent[created_at]" has a null value in JSON.');
assert(json.containsKey(r'updated_at'), 'Required key "SpatioEvent[updated_at]" is missing from JSON.');
assert(json[r'updated_at'] != null, 'Required key "SpatioEvent[updated_at]" has a null value in JSON.');
return true;
}());
return SpatioEvent(
id: mapValueOfType<String>(json, r'id')!,
title: mapValueOfType<String>(json, r'title')!,
description: mapValueOfType<String>(json, r'description'),
startTime: mapDateTime(json, r'start_time', r'')!,
endTime: mapDateTime(json, r'end_time', r'')!,
allDay: mapValueOfType<bool>(json, r'all_day')!,
location: mapValueOfType<String>(json, r'location'),
locationDetails: mapCastOfType<String, String>(json, r'location_details') ?? const {},
organizer: mapValueOfType<String>(json, r'organizer'),
attendees: Attendee.listFromJson(json[r'attendees']),
recurrenceRule: mapValueOfType<String>(json, r'recurrence_rule'),
recurrenceId: mapValueOfType<String>(json, r'recurrence_id'),
originalStart: mapDateTime(json, r'original_start', r''),
status: mapValueOfType<String>(json, r'status')!,
visibility: mapValueOfType<String>(json, r'visibility')!,
busy: mapValueOfType<bool>(json, r'busy')!,
reminders: Reminder.listFromJson(json[r'reminders']),
travelTimeMinutes: mapValueOfType<int>(json, r'travel_time_minutes'),
categories: json[r'categories'] is Iterable
? (json[r'categories'] as Iterable).cast<String>().toList(growable: false)
: const [],
color: mapValueOfType<String>(json, r'color'),
userId: mapValueOfType<String>(json, r'user_id'),
accountId: mapValueOfType<String>(json, r'account_id')!,
provider: mapValueOfType<String>(json, r'provider'),
providerId: mapValueOfType<String>(json, r'provider_id')!,
providerData: mapCastOfType<String, Object>(json, r'provider_data') ?? const {},
createdAt: mapDateTime(json, r'created_at', r'')!,
updatedAt: mapDateTime(json, r'updated_at', r'')!,
deletedAt: mapDateTime(json, r'deleted_at', r''),
syncedAt: mapDateTime(json, r'synced_at', r''),
conferenceData: ConferenceData.fromJson(json[r'conference_data']),
attachments: Attachment.listFromJson(json[r'attachments']),
url: mapValueOfType<String>(json, r'url'),
etag: mapValueOfType<String>(json, r'etag'),
sequence: mapValueOfType<int>(json, r'sequence'),
customData: mapCastOfType<String, String>(json, r'custom_data') ?? const {},
);
}
return null;
}