getPortAnchors method

  1. @override
List<PortAnchor> getPortAnchors(
  1. Size size
)
override

Gets the port anchor points for this shape.

Port anchors define where ports can attach to the node. Each anchor specifies a position and the offset where a port should be placed.

Parameters:

  • size - The size of the node

Returns a list of PortAnchor objects defining attachment points.

Implementation

@override
List<PortAnchor> getPortAnchors(Size size) {
  final centerX = size.width / 2;
  final centerY = size.height / 2;

  return [
    // Top port (90 degrees)
    PortAnchor(
      position: PortPosition.top,
      offset: Offset(centerX, 0),
      normal: const Offset(0, -1),
    ),
    // Right port (0 degrees)
    PortAnchor(
      position: PortPosition.right,
      offset: Offset(size.width, centerY),
      normal: const Offset(1, 0),
    ),
    // Bottom port (270 degrees)
    PortAnchor(
      position: PortPosition.bottom,
      offset: Offset(centerX, size.height),
      normal: const Offset(0, 1),
    ),
    // Left port (180 degrees)
    PortAnchor(
      position: PortPosition.left,
      offset: Offset(0, centerY),
      normal: const Offset(-1, 0),
    ),
  ];
}