fromJson static method
Alert?
fromJson(
- dynamic value
)
Returns a new Alert instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Alert? 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 "Alert[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Alert[$key]" has a null value in JSON.');
});
return true;
}());
return Alert(
createdAt: mapValueOfType<String>(json, r'createdAt'),
currency: mapValueOfType<String>(json, r'currency'),
enforce: mapValueOfType<bool>(json, r'enforce'),
id: mapValueOfType<String>(json, r'id'),
over: mapValueOfType<bool>(json, r'over'),
period: mapValueOfType<String>(json, r'period'),
periodSpentCents: mapValueOfType<int>(json, r'periodSpentCents'),
project: mapValueOfType<String>(json, r'project'),
rateLimitRpm: mapValueOfType<int>(json, r'rateLimitRpm'),
resetsAt: mapValueOfType<String>(json, r'resetsAt'),
service: mapValueOfType<String>(json, r'service'),
softPct: mapValueOfType<int>(json, r'softPct'),
threshold: mapValueOfType<int>(json, r'threshold'),
title: mapValueOfType<String>(json, r'title'),
triggeredAt: mapValueOfType<String>(json, r'triggeredAt'),
updatedAt: mapValueOfType<String>(json, r'updatedAt'),
userId: mapValueOfType<String>(json, r'userId'),
warn: mapValueOfType<bool>(json, r'warn'),
);
}
return null;
}