fromJson static method
Returns a new DropRateSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DropRateSchema? 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'code'),
'Required key "DropRateSchema[code]" is missing from JSON.');
assert(json[r'code'] != null,
'Required key "DropRateSchema[code]" has a null value in JSON.');
assert(json.containsKey(r'rate'),
'Required key "DropRateSchema[rate]" is missing from JSON.');
assert(json[r'rate'] != null,
'Required key "DropRateSchema[rate]" has a null value in JSON.');
assert(json.containsKey(r'min_quantity'),
'Required key "DropRateSchema[min_quantity]" is missing from JSON.');
assert(json[r'min_quantity'] != null,
'Required key "DropRateSchema[min_quantity]" has a null value in JSON.');
assert(json.containsKey(r'max_quantity'),
'Required key "DropRateSchema[max_quantity]" is missing from JSON.');
assert(json[r'max_quantity'] != null,
'Required key "DropRateSchema[max_quantity]" has a null value in JSON.');
return true;
}());
return DropRateSchema(
code: mapValueOfType<String>(json, r'code')!,
rate: mapValueOfType<int>(json, r'rate')!,
minQuantity: mapValueOfType<int>(json, r'min_quantity')!,
maxQuantity: mapValueOfType<int>(json, r'max_quantity')!,
);
}
return null;
}