paintTemporaryConnection method
void
paintTemporaryConnection(})
Implementation
void paintTemporaryConnection(
Canvas canvas,
Offset startPoint,
Offset currentPoint, {
Port? sourcePort,
Port? targetPort,
Rect? sourceNodeBounds,
Rect? targetNodeBounds,
double? animationValue,
}) {
final connectionTheme = theme.temporaryConnectionTheme;
// Always use the full connection style machinery for consistent appearance
// Calculate source endpoint positions (from the port we started dragging from)
final ({Offset endpointPos, Offset linePos}) source;
if (sourcePort != null) {
// Use proper endpoint calculation to account for endpoint marker size and gap
final startEndpoint = connectionTheme.startPoint;
final startPointSize = startEndpoint.shape is NoneMarkerShape
? Size.zero
: startEndpoint.size;
source = EndpointPositionCalculator.calculatePortConnectionPoints(
startPoint,
sourcePort.position,
startPointSize,
gap: connectionTheme.startGap,
);
} else {
source = (endpointPos: startPoint, linePos: startPoint);
}
// Calculate target endpoint positions (where we're dragging to)
final ({Offset endpointPos, Offset linePos}) target;
if (targetPort != null) {
// Use proper endpoint calculation to account for endpoint marker size and gap
// This ensures the connection snaps to the correct attachment point
final endEndpoint = connectionTheme.endPoint;
final endPointSize = endEndpoint.shape is NoneMarkerShape
? Size.zero
: endEndpoint.size;
target = EndpointPositionCalculator.calculatePortConnectionPoints(
currentPoint,
targetPort.position,
endPointSize,
gap: connectionTheme.endGap,
);
} else {
target = (endpointPos: currentPoint, linePos: currentPoint);
}
_drawConnectionWithEndpoints(
canvas,
null,
source: source,
target: target,
sourcePort: sourcePort,
targetPort: targetPort,
sourceNodeBounds: sourceNodeBounds,
targetNodeBounds: targetNodeBounds,
isSelected: false,
isTemporary: true,
drawTargetEndpoint: targetPort != null,
animationValue: animationValue,
);
}