fromJson static method
Returns a new SpecialOffer instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SpecialOffer? 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'uuid'),
'Required key "SpecialOffer[uuid]" is missing from JSON.');
assert(json[r'uuid'] != null,
'Required key "SpecialOffer[uuid]" has a null value in JSON.');
assert(json.containsKey(r'name'),
'Required key "SpecialOffer[name]" is missing from JSON.');
assert(json[r'name'] != null,
'Required key "SpecialOffer[name]" has a null value in JSON.');
assert(json.containsKey(r'desc'),
'Required key "SpecialOffer[desc]" is missing from JSON.');
assert(json[r'desc'] != null,
'Required key "SpecialOffer[desc]" has a null value in JSON.');
assert(json.containsKey(r'url'),
'Required key "SpecialOffer[url]" is missing from JSON.');
assert(json[r'url'] != null,
'Required key "SpecialOffer[url]" has a null value in JSON.');
assert(json.containsKey(r'partnerName'),
'Required key "SpecialOffer[partnerName]" is missing from JSON.');
assert(json[r'partnerName'] != null,
'Required key "SpecialOffer[partnerName]" has a null value in JSON.');
assert(json.containsKey(r'partnerImageUrl'),
'Required key "SpecialOffer[partnerImageUrl]" is missing from JSON.');
assert(json[r'partnerImageUrl'] != null,
'Required key "SpecialOffer[partnerImageUrl]" has a null value in JSON.');
assert(json.containsKey(r'productSubType'),
'Required key "SpecialOffer[productSubType]" is missing from JSON.');
assert(json[r'productSubType'] != null,
'Required key "SpecialOffer[productSubType]" has a null value in JSON.');
return true;
}());
return SpecialOffer(
uuid: mapValueOfType<String>(json, r'uuid')!,
name: mapValueOfType<String>(json, r'name')!,
desc: mapValueOfType<String>(json, r'desc')!,
url: mapValueOfType<String>(json, r'url')!,
partnerName: mapValueOfType<String>(json, r'partnerName')!,
partnerImageUrl: mapValueOfType<String>(json, r'partnerImageUrl')!,
recommendationScore: num.parse('${json[r'recommendationScore']}'),
payout: num.parse('${json[r'payout']}'),
productSubType: ProductSubType.fromJson(json[r'productSubType'])!,
disclaimer: mapValueOfType<String>(json, r'disclaimer'),
financialInstitutionUuid:
mapValueOfType<String>(json, r'financialInstitutionUuid'),
);
}
return null;
}