Node.fromJson constructor
The function Node.fromJson parses a JSON map to create a Node object with specified properties.
Args:
json (Map<String, dynamic>): The fromJson method you provided is a factory constructor for
creating a Node object from a JSON map. Here's a breakdown of the parameters used in the method:
Returns:
The Node object created from the JSON data provided in the fromJson method is being
returned.
Implementation
factory Node.fromJson(Map<String, dynamic> json) {
var node = Node(
id: json['id'],
data: NodeData.fromJson(json['data']),
position: Offset(json['position']['dx'], json['position']['dy']),
size: Size(json['size']['width'], json['size']['height']),
inputs: (json['inputPorts'] as List)
.map((portJson) => Port.fromJson(portJson))
.toList(),
outputs: (json['outputPorts'] as List)
.map((portJson) => Port.fromJson(portJson))
.toList(),
);
node._calculatePortPositions();
return node;
}