toJson method

  1. @override
Object toJson()
override

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('groundOverlayId', groundOverlayId.value);
  addIfPresent('image', image.toJson());
  addIfPresent('position', position?.toJson());
  addIfPresent('bounds', bounds?.toJson());
  addIfPresent('width', width);
  addIfPresent('height', height);
  addIfPresent(
      'anchor', anchor != null ? <Object>[anchor!.dx, anchor!.dy] : null);
  addIfPresent('bearing', bearing);
  addIfPresent('transparency', transparency);
  addIfPresent('zIndex', zIndex);
  addIfPresent('visible', visible);
  addIfPresent('clickable', clickable);
  addIfPresent('zoomLevel', zoomLevel);

  return json;
}