fromJson static method
Returns a new UserBadgeProgress instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static UserBadgeProgress? 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 "UserBadgeProgress[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "UserBadgeProgress[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "UserBadgeProgress[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "UserBadgeProgress[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'userId'), 'Required key "UserBadgeProgress[userId]" is missing from JSON.');
assert(json[r'userId'] != null, 'Required key "UserBadgeProgress[userId]" has a null value in JSON.');
assert(json.containsKey(r'firstCommentId'), 'Required key "UserBadgeProgress[firstCommentId]" is missing from JSON.');
assert(json[r'firstCommentId'] != null, 'Required key "UserBadgeProgress[firstCommentId]" has a null value in JSON.');
assert(json.containsKey(r'firstCommentDate'), 'Required key "UserBadgeProgress[firstCommentDate]" is missing from JSON.');
assert(json[r'firstCommentDate'] != null, 'Required key "UserBadgeProgress[firstCommentDate]" has a null value in JSON.');
assert(json.containsKey(r'progress'), 'Required key "UserBadgeProgress[progress]" is missing from JSON.');
assert(json[r'progress'] != null, 'Required key "UserBadgeProgress[progress]" has a null value in JSON.');
return true;
}());
return UserBadgeProgress(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
userId: mapValueOfType<String>(json, r'userId')!,
firstCommentId: mapValueOfType<String>(json, r'firstCommentId')!,
firstCommentDate: mapDateTime(json, r'firstCommentDate', r'')!,
autoTrustFactor: mapValueOfType<double>(json, r'autoTrustFactor'),
manualTrustFactor: mapValueOfType<double>(json, r'manualTrustFactor'),
progress: mapCastOfType<String, double>(json, r'progress')!,
tosAcceptedAt: mapDateTime(json, r'tosAcceptedAt', r''),
);
}
return null;
}