getConnectionPoint method
Gets the connection attachment point for a port in graph coordinates.
This is where connection lines should attach to the port. The connection point is at the port's outer edge (the edge aligned with the node boundary).
Parameters:
portId- The unique identifier of the portportSize- The size of the port widget (width x height)shape- Optional shape to use for port position calculation
Returns the absolute Offset in graph coordinates where connections attach.
Throws ArgumentError if no port with the given portId is found.
See also:
- getVisualPortOrigin for the port widget's top-left position
- getPortCenter for the visual center position
Implementation
Offset getConnectionPoint(
String portId, {
required Size portSize,
NodeShape? shape,
}) {
final port = [
...inputPorts,
...outputPorts,
].cast<Port?>().firstWhere((p) => p?.id == portId, orElse: () => null);
if (port == null) {
throw ArgumentError('Port $portId not found');
}
// Use centralized calculation from PortPosition extension
final connectionOffset = port.position.connectionOffset(portSize);
// Convert from node coordinates to absolute graph coordinates
return visualPosition.value +
getVisualPortOrigin(portId, portSize: portSize, shape: shape) +
connectionOffset;
}