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': position.dx,
  'y': position.dy,
  'width': size.width,
  'height': size.height,
  'title': currentTitle,
  'color': currentColor.toARGB32(),
  'behavior': behavior.name,
  'nodeIds': _nodeIds.toList(),
  'padding': [padding.left, padding.top, padding.right, padding.bottom],
  'zIndex': zIndex,
  'isVisible': isVisible,
  'isInteractive': isInteractive,
  'metadata': metadata,
};