fromJson static method
Returns a new AvailableService instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AvailableService? 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'id'), 'Required key "AvailableService[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "AvailableService[id]" has a null value in JSON.');
assert(json.containsKey(r'type'), 'Required key "AvailableService[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "AvailableService[type]" has a null value in JSON.');
assert(json.containsKey(r'price'), 'Required key "AvailableService[price]" is missing from JSON.');
assert(json[r'price'] != null, 'Required key "AvailableService[price]" has a null value in JSON.');
return true;
}());
return AvailableService(
id: mapValueOfType<String>(json, r'id')!,
type: mapValueOfType<String>(json, r'type')!,
price: Money.fromJson(json[r'price'])!,
passengerIndexes: json[r'passengerIndexes'] is Iterable
? (json[r'passengerIndexes'] as Iterable).cast<int>().toList(growable: false)
: const [],
segments: SegmentPosition.listFromJson(json[r'segments']),
maxQuantity: mapValueOfType<int>(json, r'maxQuantity'),
baggage: BaggageLimits.fromJson(json[r'baggage']),
);
}
return null;
}