targetPosition property

PortPosition get targetPosition

Get target port position.

When a target port is available, returns its position. When no target port (e.g., temporary connection dragging FROM an output port), returns the opposite of the source port's position for smooth line flow.

Implementation

PortPosition get targetPosition {
  // If we have a target port, use its position
  if (targetPort != null) {
    return targetPort!.position;
  }

  // For temporary connections dragging from an OUTPUT port:
  // - The output port becomes the SOURCE (sourcePort is set)
  // - The mouse position becomes the TARGET (targetPort is null)
  // - Use opposite of source position so line flows naturally from the output
  if (sourcePort != null) {
    return _oppositePosition(sourcePort!.position);
  }

  // Fallback (shouldn't happen in practice)
  return PortPosition.left;
}