setNodePorts method

void setNodePorts(
  1. String nodeId, {
  2. List<Port>? inputPorts,
  3. List<Port>? outputPorts,
})

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.

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(() {
    if (inputPorts != null) {
      node.inputPorts.clear();
      node.inputPorts.addAll(inputPorts);
    }

    if (outputPorts != null) {
      node.outputPorts.clear();
      node.outputPorts.addAll(outputPorts);
    }
  });
}