User.fromJson constructor
User.fromJson(
- Map<String, dynamic> jsonRes
)
Implementation
factory User.fromJson(Map<String, dynamic> jsonRes) {
final roles = jsonRes['roles'] is List ? <Roles>[] : null;
if (roles != null) {
for (final dynamic item in jsonRes['roles']!) {
if (item != null) {
tryCatch(() {
roles.add(Roles.fromJson(asT<Map<String, dynamic>>(item)!));
});
}
}
}
final resourcesCategories =
jsonRes['resourcesCategories'] is List ? <Object>[] : null;
if (resourcesCategories != null) {
for (final dynamic item in jsonRes['resourcesCategories']!) {
if (item != null) {
tryCatch(() {
resourcesCategories.add(asT<Object>(item)!);
});
}
}
}
return User(
id: asT<int>(jsonRes['id'])!,
loginNumber: asT<String>(jsonRes['loginNumber'])!,
nickName: asT<String>(jsonRes['nickName'])!,
email: asT<String>(jsonRes['email']??'')!,
picture: asT<String>(jsonRes['picture'])!,
phone: asT<String>(jsonRes['phone']??'')!,
password: asT<String>(jsonRes['password'])!,
loginTime: asT<String>(jsonRes['loginTime']??'')!,
type: asT<int>(jsonRes['type'])!,
roles: roles!,
resourcesCategories: resourcesCategories!,
status: asT<int>(jsonRes['status'])!,
salt: asT<String>(jsonRes['salt'])!,
);
}