fromJson static method
Returns a new PositionNMEAGSA instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PositionNMEAGSA? 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 "PositionNMEAGSA[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "PositionNMEAGSA[$key]" has a null value in JSON.');
});
return true;
}());
return PositionNMEAGSA(
sentence: mapValueOfType<String>(json, r'sentence'),
type: mapValueOfType<String>(json, r'type'),
selectionMode: mapValueOfType<String>(json, r'selectionMode'),
mode:
json[r'mode'] == null ? null : num.parse(json[r'mode'].toString()),
satellites: json[r'satellites'] is List
? (json[r'satellites'] as List).cast<num>()
: const [],
PDOP:
json[r'PDOP'] == null ? null : num.parse(json[r'PDOP'].toString()),
HDOP:
json[r'HDOP'] == null ? null : num.parse(json[r'HDOP'].toString()),
VDOP:
json[r'VDOP'] == null ? null : num.parse(json[r'VDOP'].toString()),
talkerId: mapValueOfType<String>(json, r'talker_id'),
);
}
return null;
}