getPortWorldPosition method
Gets the world position of a port.
Returns the center position of the port in graph coordinates.
Returns null if the node or port doesn't exist.
Example:
final position = controller.getPortWorldPosition('node1', 'output1');
if (position != null) {
print('Port at: $position');
}
Implementation
Offset? getPortWorldPosition(String nodeId, String portId) {
final node = _nodes[nodeId];
if (node == null) return null;
final port = getPort(nodeId, portId);
if (port == null) return null;
// Use the node's getPortCenter method which handles coordinate conversion
// We need the theme to get the port size for accurate calculations
if (_theme == null) return null;
final portSize = _theme!.portTheme.resolveSize(port);
try {
return node.getPortCenter(
portId,
portSize: portSize,
shape: _nodeShapeBuilder?.call(node),
);
} catch (_) {
return null;
}
}