GroupAnnotation.fromJsonMap constructor

GroupAnnotation.fromJsonMap(
  1. Map<String, dynamic> json
)

Creates a GroupAnnotation from a JSON map.

This factory method is used during workflow deserialization to recreate group annotations from saved data.

Implementation

factory GroupAnnotation.fromJsonMap(Map<String, dynamic> json) {
  final annotation = GroupAnnotation(
    id: json['id'] as String,
    position: Offset(
      (json['x'] as num).toDouble(),
      (json['y'] as num).toDouble(),
    ),
    title: json['title'] as String? ?? '',
    padding: json['padding'] != null
        ? EdgeInsets.fromLTRB(
            (json['padding']['left'] as num?)?.toDouble() ?? 20.0,
            (json['padding']['top'] as num?)?.toDouble() ?? 20.0,
            (json['padding']['right'] as num?)?.toDouble() ?? 20.0,
            (json['padding']['bottom'] as num?)?.toDouble() ?? 20.0,
          )
        : const EdgeInsets.all(20),
    color: Color(json['color'] as int? ?? Colors.blue.toARGB32()),
    zIndex: json['zIndex'] as int? ?? -1,
    isVisible: json['isVisible'] as bool? ?? true,
    isInteractive: json['isInteractive'] as bool? ?? true,
    dependencies:
        (json['dependencies'] as List?)?.cast<String>().toSet() ?? {},
    metadata: json['metadata'] as Map<String, dynamic>? ?? {},
  );
  return annotation;
}