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