TemporaryConnection class

Represents a temporary connection during a drag-and-drop operation.

A TemporaryConnection is created when a user starts dragging from a port and is updated as the mouse/pointer moves. It becomes a permanent connection when dropped on a valid target port, or is discarded if the drag is cancelled.

Port Direction Semantics

The isStartFromOutput flag determines the logical role of each endpoint:

  • When true (dragging from output): start port is SOURCE, mouse is TARGET
  • When false (dragging from input): start port is TARGET, mouse is SOURCE

This is important for path routing - connections always flow from source to target.

Immutable Properties (Set at Start)

Observable Properties (Change During Drag)

  • currentPoint: Current pointer position
  • targetNodeId: ID of the hovered node (null until hovering over valid target)
  • targetPortId: ID of the hovered port (null until hovering over valid target)
  • targetNodeBounds: Bounds of the hovered node (null until hovering)

Usage Example

// Create when drag starts from an output port
final tempConnection = TemporaryConnection(
  startPoint: portPosition,
  startNodeId: 'node-1',
  startPortId: 'port-out',
  isStartFromOutput: true,
  startNodeBounds: node.getBounds(),
  initialCurrentPoint: portPosition,
);

// Update as pointer moves
tempConnection.currentPoint = newPointerPosition;

// Set target when hovering over a valid port
tempConnection.targetNodeId = 'node-2';
tempConnection.targetPortId = 'port-in';
tempConnection.targetNodeBounds = targetNode.getBounds();

See also:

Constructors

TemporaryConnection({required Offset startPoint, required String startNodeId, required String startPortId, required bool isStartFromOutput, required Rect startNodeBounds, required Offset initialCurrentPoint, String? targetNodeId, String? targetPortId, Rect? targetNodeBounds})
Creates a temporary connection for drag-and-drop operations.

Properties

currentPoint Offset
The current pointer position.
getter/setter pair
currentPointObservable → Observable<Offset>
Gets the MobX observable for the current point.
no setter
hashCode int
The hash code for this object.
no setteroverride
isStartFromOutput bool
Whether the drag started from an output port.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startNodeBounds Rect
Bounds of the node where the drag started.
final
startNodeId String
ID of the node where the drag started.
final
startPoint Offset
The position where the drag started (port position).
final
startPortId String
ID of the port where the drag started.
final
targetNodeBounds Rect?
Bounds of the hovered node.
getter/setter pair
targetNodeBoundsObservable → Observable<Rect?>
Gets the MobX observable for the target node bounds.
no setter
targetNodeId String?
ID of the hovered node.
getter/setter pair
targetNodeIdObservable → Observable<String?>
Gets the MobX observable for the target node ID.
no setter
targetPortId String?
ID of the hovered port.
getter/setter pair
targetPortIdObservable → Observable<String?>
Gets the MobX observable for the target port ID.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override