toJson method

Map<String, dynamic> toJson(
  1. Object? toJsonT(
    1. T value
    )
)

Converts the node to a JSON map.

This method serializes the node to a JSON-compatible map. The custom data type T must be serialized using the provided toJsonT function.

Parameters:

  • toJsonT - Function to serialize the custom data of type T

Returns a JSON-compatible Map containing the node's data.

Implementation

Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => {
  'id': id,
  'type': type,
  'size': const SizeConverter().toJson(size.value),
  'inputPorts': inputPorts.map((e) => e.toJson()).toList(),
  'outputPorts': outputPorts.map((e) => e.toJson()).toList(),
  'data': toJsonT(data),
  'position': const OffsetConverter().toJson(position.value),
  'zIndex': zIndex.value,
  'selected': selected.value,
};