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('polylineId', polylineId.value);
  addIfPresent('consumeTapEvents', consumeTapEvents);
  addIfPresent('color', color.value);
  addIfPresent('endCap', endCap.toJson());
  addIfPresent('geodesic', geodesic);
  addIfPresent('jointType', jointType.value);
  addIfPresent('startCap', startCap.toJson());
  addIfPresent('visible', visible);
  addIfPresent('width', width);
  addIfPresent('zIndex', zIndex);

  json['points'] = _pointsToJson();

  json['pattern'] = _patternToJson();

  return json;
}