getPortCenterAbsolute method
The function getPortCenterAbsolute calculates the absolute center position of a port based on
its index and whether it is an output port or not.
Args:
index (int): The index parameter represents the index of the port within the portList
(either outputPorts or inputPorts) for which you want to calculate the center position.
isOutput (bool): The isOutput parameter is a boolean value that indicates whether the port is
an output port or not. If isOutput is true, it means the port is an output port; otherwise, it
is an input port.
Returns:
The function getPortCenterAbsolute returns an Offset object with the x-coordinate calculated
based on the position of the port and whether it is an output port or not, and the y-coordinate
based on the position of the port.
Implementation
Offset getPortCenterAbsolute(int index, bool isOutput) {
final portList = isOutput ? outputPorts : inputPorts;
final portPosition = portList[index].position;
final double xOffset = isOutput ? size.width : 0;
return Offset(
position.dx + xOffset,
position.dy + portPosition.dy,
);
}