hitTestPort method
Hit test for a port at the given graph position.
Returns a record containing (nodeId, portId, isOutput) if a port is found at the position, otherwise returns null.
This is useful for finding target ports during connection drag operations.
Example:
final result = controller.hitTestPort(graphPosition);
if (result != null) {
print('Found port ${result.portId} on node ${result.nodeId}');
}
Implementation
({String nodeId, String portId, bool isOutput})? hitTestPort(
Offset graphPosition,
) {
final result = _spatialIndex.hitTestPort(graphPosition);
if (result != null && result.portId != null) {
return (
nodeId: result.nodeId!,
portId: result.portId!,
isOutput: result.isOutput ?? false,
);
}
return null;
}