User.fromMap constructor
Implementation
User.fromMap(Map<String, dynamic>? json) {
if (json != null) {
id = json['_id'];
name = json['name'];
if (json['emails'] != null) {
List<dynamic> jsonList = json['emails'].runtimeType == String //
? jsonDecode(json['emails'])
: json['emails'];
emails = jsonList
.where((json) => json != null)
.map((json) => Email.fromMap(json))
.toList();
} else {
emails = null;
}
status = json['status'];
statusConnection = json['statusConnection'];
username = json['username'];
utcOffset = json['utcOffset'];
active = json['active'];
if (json['roles'] != null) {
List<dynamic> jsonList = json['roles'].runtimeType == String //
? jsonDecode(json['roles'])
: json['roles'];
roles = jsonList
.where((json) => json != null)
.map((value) => value.toString())
.toList();
} else {
roles = null;
}
if (json['settings'] != null) {
Map<String, dynamic> jsonSettings =
json['settings'].runtimeType == String //
? jsonDecode(json['settings'])
: json['settings'];
if (jsonSettings['preferences'] != null) {
settings = {
'preferences': Preferences.fromMap(jsonSettings['preferences'])
};
}
}
avatarUrl = json['avatarUrl'];
if (json['customFields'] != null) {
customFields = Map<String, String>.from(json['customFields']);
}
success = json['success'];
}
}