fromJson static method
Returns a new Partner instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Partner? 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 "Partner[uuid]" is missing from JSON.');
assert(json[r'uuid'] != null,
'Required key "Partner[uuid]" has a null value in JSON.');
assert(json.containsKey(r'name'),
'Required key "Partner[name]" is missing from JSON.');
assert(json[r'name'] != null,
'Required key "Partner[name]" has a null value in JSON.');
assert(json.containsKey(r'description'),
'Required key "Partner[description]" is missing from JSON.');
assert(json[r'description'] != null,
'Required key "Partner[description]" has a null value in JSON.');
assert(json.containsKey(r'disclaimer'),
'Required key "Partner[disclaimer]" is missing from JSON.');
assert(json[r'disclaimer'] != null,
'Required key "Partner[disclaimer]" has a null value in JSON.');
assert(json.containsKey(r'supportsPreSelect'),
'Required key "Partner[supportsPreSelect]" is missing from JSON.');
assert(json[r'supportsPreSelect'] != null,
'Required key "Partner[supportsPreSelect]" has a null value in JSON.');
assert(json.containsKey(r'shouldDisplayPreSelect'),
'Required key "Partner[shouldDisplayPreSelect]" is missing from JSON.');
assert(json[r'shouldDisplayPreSelect'] != null,
'Required key "Partner[shouldDisplayPreSelect]" has a null value in JSON.');
assert(json.containsKey(r'supportsPersonalizedOffers'),
'Required key "Partner[supportsPersonalizedOffers]" is missing from JSON.');
assert(json[r'supportsPersonalizedOffers'] != null,
'Required key "Partner[supportsPersonalizedOffers]" has a null value in JSON.');
assert(json.containsKey(r'imageUrl'),
'Required key "Partner[imageUrl]" is missing from JSON.');
assert(json[r'imageUrl'] != null,
'Required key "Partner[imageUrl]" has a null value in JSON.');
return true;
}());
return Partner(
uuid: mapValueOfType<String>(json, r'uuid')!,
name: mapValueOfType<String>(json, r'name')!,
description: mapValueOfType<String>(json, r'description')!,
disclaimer: mapValueOfType<String>(json, r'disclaimer')!,
supportsPreSelect: mapValueOfType<bool>(json, r'supportsPreSelect')!,
shouldDisplayPreSelect:
mapValueOfType<bool>(json, r'shouldDisplayPreSelect')!,
supportsPersonalizedOffers:
mapValueOfType<bool>(json, r'supportsPersonalizedOffers')!,
imageUrl: mapValueOfType<String>(json, r'imageUrl')!,
subtextOverride: mapValueOfType<String>(json, r'subtextOverride'),
headquarters: mapValueOfType<String>(json, r'headquarters'),
assets: mapValueOfType<String>(json, r'assets'),
brandName: mapValueOfType<String>(json, r'brandName'),
brandUuid: mapValueOfType<String>(json, r'brandUuid'),
);
}
return null;
}