setNodePorts method
Sets the input and/or output ports of a node.
This replaces the existing ports with the provided lists. Pass null to
leave a port type unchanged.
Does nothing if the node with nodeId doesn't exist.
Parameters:
nodeId: The ID of the node to updateinputPorts: New list of input ports (optional)outputPorts: New list of output ports (optional)
Example:
controller.setNodePorts(
'node1',
inputPorts: [Port(id: 'in1', label: 'Input')],
outputPorts: [Port(id: 'out1', label: 'Output')],
);
Implementation
void setNodePorts(
String nodeId, {
List<Port>? inputPorts,
List<Port>? outputPorts,
}) {
final node = _nodes[nodeId];
if (node == null) return;
runInAction(() {
// Update input ports if provided
if (inputPorts != null) {
node.inputPorts.clear();
node.inputPorts.addAll(inputPorts);
}
// Update output ports if provided
if (outputPorts != null) {
node.outputPorts.clear();
node.outputPorts.addAll(outputPorts);
}
});
}