createConnection method

void createConnection(
  1. String sourceNodeId,
  2. String sourcePortId,
  3. String targetNodeId,
  4. String targetPortId,
)

Creates a connection between two ports.

This is a convenience method that creates a Connection object with an auto-generated ID and adds it to the graph.

Parameters:

  • sourceNodeId: The ID of the source node
  • sourcePortId: The ID of the output port on the source node
  • targetNodeId: The ID of the target node
  • targetPortId: The ID of the input port on the target node

Example:

controller.createConnection(
  'node1',
  'output1',
  'node2',
  'input1',
);

Implementation

void createConnection(
  String sourceNodeId,
  String sourcePortId,
  String targetNodeId,
  String targetPortId,
) {
  final connection = Connection(
    id: 'conn_${DateTime.now().millisecondsSinceEpoch}',
    sourceNodeId: sourceNodeId,
    sourcePortId: sourcePortId,
    targetNodeId: targetNodeId,
    targetPortId: targetPortId,
  );
  addConnection(connection);
}