toJson method Null safety

Object toJson()
override

Converts this object to something serializable in JSON.

Implementation

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

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

  addIfPresent('circleId', circleId.value);
  addIfPresent('consumeTapEvents', consumeTapEvents);
  addIfPresent('fillColor', fillColor.value);
  addIfPresent('center', center.toJson());
  addIfPresent('radius', radius);
  addIfPresent('strokeColor', strokeColor.value);
  addIfPresent('strokeWidth', strokeWidth);
  addIfPresent('visible', visible);
  addIfPresent('zIndex', zIndex);

  return json;
}