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