fromJson static method
Returns a new InvoiceLineItem instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static InvoiceLineItem? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "InvoiceLineItem[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "InvoiceLineItem[$key]" has a null value in JSON.');
});
return true;
}());
return InvoiceLineItem(
amount: mapValueOfType<int>(json, r'amount'),
currency: mapValueOfType<String>(json, r'currency'),
description: mapValueOfType<String>(json, r'description'),
id: mapValueOfType<String>(json, r'id'),
meterId: mapValueOfType<String>(json, r'meterId'),
periodEnd: mapValueOfType<String>(json, r'periodEnd'),
periodStart: mapValueOfType<String>(json, r'periodStart'),
planId: mapValueOfType<String>(json, r'planId'),
planName: mapValueOfType<String>(json, r'planName'),
quantity: mapValueOfType<int>(json, r'quantity'),
type: mapValueOfType<String>(json, r'type'),
unitPrice: mapValueOfType<int>(json, r'unitPrice'),
);
}
return null;
}