toMap method

  1. @override
Map<String, dynamic> toMap()
override

Converts this transform object to a Map.

Returns a Map representing the properties of this layer object, including the X and Y coordinates, rotation angle, scale factors, and flip flags.

Implementation

@override
Map<String, dynamic> toMap() {
  return {
    ...super.toMap(),
    'text': text,
    'colorMode': LayerBackgroundMode.values[colorMode?.index ?? 0].name,
    'color': color.value,
    'background': background.value,
    'colorPickerPosition': colorPickerPosition ?? 0,
    'align': align.name,
    'fontScale': fontScale,
    'type': 'text',
    if (customSecondaryColor) 'customSecondaryColor': customSecondaryColor,
    if (textStyle?.fontFamily != null) 'fontFamily': textStyle?.fontFamily,
    if (textStyle?.fontStyle != null) 'fontStyle': textStyle?.fontStyle!.name,
    if (textStyle?.fontWeight != null)
      'fontWeight': textStyle?.fontWeight!.value,
    if (textStyle?.letterSpacing != null)
      'letterSpacing': textStyle?.letterSpacing,
    if (textStyle?.height != null) 'height': textStyle?.height,
    if (textStyle?.wordSpacing != null) 'wordSpacing': textStyle?.wordSpacing,
    if (textStyle?.decoration != null)
      'decoration': textStyle?.decoration.toString(),
  };
}