toJson method

dynamic toJson()

Converts this object to something serializable in JSON.

Implementation

dynamic toJson() {
  final Map<String, dynamic> json = <String, dynamic>{};

  void addIfPresent(String fieldName, dynamic value) {
    if (value != null) {
      json[fieldName] = value;
    }
  }

  json['latlng'] = latLng.toJson();
  addIfPresent('provider', provider);
  addIfPresent('accuracy', accuracy);
  addIfPresent('altitude', altitude);
  addIfPresent('bearing', bearing);
  addIfPresent('speed', speed);
  addIfPresent('time', time);
  return json;
}