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,
  'markerType': markerType.name,
  'markerSize': markerSize,
  'color': color.toARGB32(),
  'tooltip': tooltip,
  'zIndex': currentZIndex,
  'isVisible': currentIsVisible,
  'isInteractive': isInteractive,
  'dependencies': dependencies.toList(),
  'metadata': metadata,
};