createConnection method
void
createConnection()
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 nodesourcePortId: The ID of the output port on the source nodetargetNodeId: The ID of the target nodetargetPortId: 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);
}