removePort method

void removePort(
  1. String nodeId,
  2. String portId
)

Removes a port from a node and all connections involving that port.

This method will:

  1. Remove all connections where this port is the source or target
  2. Remove the port from the node

Does nothing if the node with nodeId doesn't exist.

Parameters:

  • nodeId: The ID of the node containing the port
  • portId: The ID of the port to remove

Implementation

void removePort(String nodeId, String portId) {
  final node = _nodes[nodeId];
  if (node == null) return;

  runInAction(() {
    // Remove any connections involving this port
    _connections.removeWhere(
      (c) =>
          (c.sourceNodeId == nodeId && c.sourcePortId == portId) ||
          (c.targetNodeId == nodeId && c.targetPortId == portId),
    );

    // Remove the port using the node's dynamic method
    node.removePort(portId);
  });
}