toJson method

dynamic toJson()

Implementation

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

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

  addIfPresent('id', id);
  addIfPresent('name', name);
  addIfPresent('latLng', latLng?.toJson());
  return json;
}