fromJson static method
Returns a new DestinationStatus instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DestinationStatus? 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 "DestinationStatus[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "DestinationStatus[$key]" has a null value in JSON.');
});
return true;
}());
return DestinationStatus(
account: mapValueOfType<String>(json, r'account'),
category: mapValueOfType<String>(json, r'category'),
config: mapCastOfType<String, String>(json, r'config') ?? const {},
connected: mapValueOfType<bool>(json, r'connected'),
enabled: mapValueOfType<bool>(json, r'enabled'),
fields: DestinationField.listFromJson(json[r'fields']),
live: mapValueOfType<bool>(json, r'live'),
name: mapValueOfType<String>(json, r'name'),
pixel: mapValueOfType<bool>(json, r'pixel'),
platform: mapValueOfType<String>(json, r'platform'),
secrets: json[r'secrets'] is Iterable
? (json[r'secrets'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;
}