toJson method

  1. @override
Object toJson()

Converts this object to something serializable in JSON.

Implementation

@override
Object toJson() {
  final Map<String, Object> json = <String, Object>{};

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

  addIfPresent('heatmapId', heatmapId.value);
  addIfPresent('data', data.map((WeightedLatLng e) => e.toJson()).toList());
  addIfPresent('dissipating', dissipating);
  addIfPresent('gradient', gradient?.toJson());
  addIfPresent('maxIntensity', maxIntensity);
  addIfPresent('opacity', opacity);
  addIfPresent('radius', radius.radius);
  addIfPresent('minimumZoomIntensity', minimumZoomIntensity);
  addIfPresent('maximumZoomIntensity', maximumZoomIntensity);

  return json;
}