toJson method

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

Serializes this annotation to JSON.

Implement this to define how your custom annotation is persisted. Include all properties needed to recreate the annotation.

The JSON should include at minimum:

  • 'id': The annotation's unique identifier
  • 'type': The annotation type string
  • 'x', 'y': Position coordinates
  • Any custom properties specific to your annotation

Implementation

@override
Map<String, dynamic> toJson() => {
  'id': id,
  'type': type,
  'x': currentPosition.dx,
  'y': currentPosition.dy,
  'title': currentTitle,
  'padding': {
    'left': padding.left,
    'top': padding.top,
    'right': padding.right,
    'bottom': padding.bottom,
  },
  'color': currentColor.toARGB32(),
  'zIndex': currentZIndex,
  'isVisible': currentIsVisible,
  'isInteractive': isInteractive,
  'dependencies': dependencies.toList(),
  'metadata': metadata,
};