toJson method
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 typeT
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,
};