DragSession class abstract

Abstract interface for a drag session.

A drag session manages the lifecycle of a drag operation, handling canvas locking/unlocking automatically. Elements only need to:

  • Request a session from the controller via createSession(type)
  • Call lifecycle methods: start, end, cancel

Elements manage their own business state (positions, sizes) internally. The session purely handles canvas lock coordination.

Usage

// In widget - get session from controller
DragSession? _session;

void _handleDragStart(DragStartDetails details) {
  _originalPosition = widget.position; // Element manages its own state
  _session = controller.createSession(DragSessionType.nodeDrag);
  _session!.start(); // Locks canvas
  // ...
}

void _handleDragEnd(DragEndDetails details) {
  _session?.end(); // Unlocks canvas
  _session = null;
  // Commit state (no restore needed)
}

void _handleDragCancel() {
  _session?.cancel(); // Unlocks canvas
  _session = null;
  // Restore state
  widget.position = _originalPosition!;
}

Design

The controller owns session creation, ensuring centralized control over canvas locking. Elements don't need direct access to InteractionState; they only interact with this abstract session API. The implementation is private within the controller.

Constructors

DragSession()

Properties

hashCode int
The hash code for this object.
no setterinherited
isActive bool
Whether this session is currently active.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type DragSessionType
The type of this drag session.
no setter

Methods

cancel() → void
Cancels the drag session.
end() → void
Ends the drag session successfully.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start() → void
Starts the drag session.
toString() String
A string representation of this object.
inherited

Operators

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