fromJson static method

PositionNMEAGGA? fromJson(
  1. dynamic value
)

Returns a new PositionNMEAGGA instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static PositionNMEAGGA? 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 "PositionNMEAGGA[$key]" is missing from JSON.');
        assert(json[key] != null,
            'Required key "PositionNMEAGGA[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return PositionNMEAGGA(
      sentence: mapValueOfType<String>(json, r'sentence'),
      type: mapValueOfType<String>(json, r'type'),
      timestamp: mapValueOfType<String>(json, r'timestamp'),
      lat: mapValueOfType<String>(json, r'lat'),
      latPole: mapValueOfType<String>(json, r'latPole'),
      lon: mapValueOfType<String>(json, r'lon'),
      lonPole: mapValueOfType<String>(json, r'lonPole'),
      fixType: mapValueOfType<String>(json, r'fixType'),
      numSat: json[r'numSat'] == null
          ? null
          : num.parse(json[r'numSat'].toString()),
      horDilution: json[r'horDilution'] == null
          ? null
          : num.parse(json[r'horDilution'].toString()),
      alt: json[r'alt'] == null ? null : num.parse(json[r'alt'].toString()),
      altUnit: mapValueOfType<String>(json, r'altUnit'),
      geoidalSep: json[r'geoidalSep'] == null
          ? null
          : num.parse(json[r'geoidalSep'].toString()),
      geoidalSepUnit: mapValueOfType<String>(json, r'geoidalSepUnit'),
      differentialAge: json[r'differentialAge'] == null
          ? null
          : num.parse(json[r'differentialAge'].toString()),
      differentialRefStn: mapValueOfType<String>(json, r'differentialRefStn'),
      talkerId: mapValueOfType<String>(json, r'talker_id'),
    );
  }
  return null;
}