fromJsonMap<R> static method

CommentNode<R> fromJsonMap<R>(
  1. Map<String, dynamic> json,
  2. R fromJsonT(
    1. Object? json
    )
)

Creates a CommentNode from a JSON map.

This factory method is used during workflow deserialization to recreate comment nodes from saved data.

Parameters:

  • json - The JSON map containing node data
  • fromJsonT - Function to deserialize the custom data of type R

Implementation

static CommentNode<R> fromJsonMap<R>(
  Map<String, dynamic> json,
  R Function(Object? json) fromJsonT,
) {
  return CommentNode<R>(
    id: json['id'] as String,
    position: Offset(
      (json['x'] as num).toDouble(),
      (json['y'] as num).toDouble(),
    ),
    text: json['text'] as String? ?? '',
    data: fromJsonT(json['data']),
    width: (json['width'] as num?)?.toDouble() ?? 200.0,
    height: (json['height'] as num?)?.toDouble() ?? 100.0,
    color: Color(json['color'] as int? ?? Colors.yellow.toARGB32()),
    zIndex: json['zIndex'] as int? ?? 0,
    isVisible: json['isVisible'] as bool? ?? true,
    locked: json['locked'] as bool? ?? false,
  );
}