EventNotificationModel.fromJson constructor
EventNotificationModel.fromJson(
- Map<String, dynamic> data
)
Implementation
EventNotificationModel.fromJson(Map<String, dynamic> data) {
title = data['title'] ?? '';
key = data['key'] ?? '';
atsignCreator = data['atsignCreator'] ?? '';
isCancelled = data['isCancelled'] == 'true' ? true : false;
isSharing = data['isSharing'] == 'true' ? true : false;
isUpdate = data['isUpdate'] == 'true' ? true : false;
lat = data['lat'] != 'null' && data['lat'] != null
? double.parse(data['lat'])
: null;
long = data['long'] != 'null' && data['long'] != null
? double.parse(data['long'])
: null;
if (data['venue'] != null) {
venue = Venue.fromJson(jsonDecode(data['venue']));
}
if (data['event'] != null) {
event = data['event'] != null
? Event.fromJson(jsonDecode(data['event']))
: null;
}
if (data['group'] != null) {
data['group'] = jsonDecode(data['group']);
group = AtGroup(data['group']['name']);
data['group']['members'].forEach((contact) {
var newContact = AtContact(atSign: contact['atSign']);
newContact.tags = {};
newContact.tags!['isAccepted'] = contact['tags']['isAccepted'];
newContact.tags!['isSharing'] = contact['tags']['isSharing'];
newContact.tags!['isExited'] = contact['tags']['isExited'];
newContact.tags!['shareFrom'] = contact['tags']['shareFrom'] != null &&
contact['tags']['shareFrom'] != 'null'
? contact['tags']['shareFrom']
: -1;
newContact.tags!['shareTo'] = contact['tags']['shareTo'] != null &&
contact['tags']['shareTo'] != 'null'
? contact['tags']['shareTo']
: -1;
newContact.tags!['lat'] =
contact['tags']['lat'] != null && contact['tags']['lat'] != 'null'
? double.parse(contact['tags']['lat'].toString())
: null;
newContact.tags!['long'] =
contact['tags']['long'] != null && contact['tags']['long'] != 'null'
? double.parse(contact['tags']['long'].toString())
: null;
group!.members!.add(newContact);
});
}
}