fromJson static method
MmUser?
fromJson(
- dynamic value
)
Returns a new MmUser instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static MmUser? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "MmUser[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "MmUser[$key]" has a null value in JSON.');
});
return true;
}());
return MmUser(
id: mapValueOfType<String>(json, r'id'),
createAt: mapValueOfType<int>(json, r'create_at'),
updateAt: mapValueOfType<int>(json, r'update_at'),
deleteAt: mapValueOfType<int>(json, r'delete_at'),
username: mapValueOfType<String>(json, r'username'),
firstName: mapValueOfType<String>(json, r'first_name'),
lastName: mapValueOfType<String>(json, r'last_name'),
nickname: mapValueOfType<String>(json, r'nickname'),
email: mapValueOfType<String>(json, r'email'),
emailVerified: mapValueOfType<bool>(json, r'email_verified'),
authService: mapValueOfType<String>(json, r'auth_service'),
roles: mapValueOfType<String>(json, r'roles'),
locale: mapValueOfType<String>(json, r'locale'),
notifyProps: MmUserNotifyProps.fromJson(json[r'notify_props']),
props: mapValueOfType<Map>(json, r'props'),
lastPasswordUpdate: mapValueOfType<int>(json, r'last_password_update'),
lastPictureUpdate: mapValueOfType<int>(json, r'last_picture_update'),
failedAttempts: mapValueOfType<int>(json, r'failed_attempts'),
mfaActive: mapValueOfType<bool>(json, r'mfa_active'),
timezone: MmTimezone.fromJson(json[r'timezone']),
termsOfServiceId: mapValueOfType<String>(json, r'terms_of_service_id'),
termsOfServiceCreateAt: mapValueOfType<int>(json, r'terms_of_service_create_at'),
);
}
return null;
}