toJson method
dynamic
toJson(
[ - bool addGeometry = true
])
Implementation
dynamic toJson([bool addGeometry = true]) {
final json = <String, dynamic>{};
void addIfPresent(String fieldName, dynamic value) {
if (value != null) {
json[fieldName] = value;
}
}
addIfPresent('iconSize', iconSize);
addIfPresent('iconImage', iconImage);
addIfPresent('iconRotate', iconRotate);
addIfPresent('iconOffset', _offsetToJson(iconOffset));
addIfPresent('iconAnchor', iconAnchor);
addIfPresent('fontNames', fontNames);
addIfPresent('textField', textField);
addIfPresent('textSize', textSize);
addIfPresent('textMaxWidth', textMaxWidth);
addIfPresent('textLetterSpacing', textLetterSpacing);
addIfPresent('textJustify', textJustify);
addIfPresent('textAnchor', textAnchor);
addIfPresent('textRotate', textRotate);
addIfPresent('textTransform', textTransform);
addIfPresent('textOffset', _offsetToJson(textOffset));
addIfPresent('iconOpacity', iconOpacity);
addIfPresent('iconColor', iconColor.toHex());
addIfPresent('iconHaloColor', iconHaloColor.toHex());
addIfPresent('iconHaloWidth', iconHaloWidth);
addIfPresent('iconHaloBlur', iconHaloBlur);
addIfPresent('textOpacity', textOpacity);
addIfPresent('textColor', textColor.toHex());
addIfPresent('textHaloColor', textHaloColor.toHex());
addIfPresent('textHaloWidth', textHaloWidth);
addIfPresent('textHaloBlur', textHaloBlur);
if (addGeometry) {
addIfPresent('geometry', geometry?.toJson());
}
addIfPresent('zIndex', zIndex);
addIfPresent('draggable', draggable);
return json;
}