fromJson static method
Returns a new AirtimeInputs instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AirtimeInputs? 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'phoneNumber'), 'Required key "AirtimeInputs[phoneNumber]" is missing from JSON.');
assert(json[r'phoneNumber'] != null, 'Required key "AirtimeInputs[phoneNumber]" has a null value in JSON.');
return true;
}());
return AirtimeInputs(
phoneNumber: mapValueOfType<String>(json, r'phoneNumber')!,
settings: mapCastOfType<String, String>(json, r'settings') ?? const {},
minDeliveredValue: MoneyInput.fromJson(json[r'minDeliveredValue']),
value: MoneyInput.fromJson(json[r'value']),
maxPrice: MoneyInput.fromJson(json[r'maxPrice']),
);
}
return null;
}