toMap method

Map<String, dynamic> toMap()

Converts the PaintedModel instance into a map.

Implementation

Map<String, dynamic> toMap() {
  /// List to hold the offset points as maps.
  List<Map<String, double>> offsetMaps = [];

  /// Iterate over the offsets and add them to the list as maps.
  for (var offset in offsets) {
    if (offset != null) {
      offsetMaps.add({'x': offset.dx, 'y': offset.dy});
    }
  }

  /// Returns a map representation of the PaintedModel instance.
  return {
    'mode': mode.name,
    'offsets': offsetMaps,
    'color': color.value,
    'strokeWidth': strokeWidth,
    'opacity': opacity,
    'fill': fill,
  };
}