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