createSession property
Factory function to create a DragSession for this element.
When provided, ElementScope manages the session lifecycle:
- On drag start: calls createSession, then DragSession.start (locks canvas)
- On drag end: calls DragSession.end (unlocks canvas)
- On drag cancel: calls DragSession.cancel (unlocks canvas)
Elements manage their own business state (positions, sizes) internally. The session purely handles canvas lock coordination.
Example:
ElementScope(
createSession: () => controller.createSession(),
onDragStart: (_) => controller.startNodeDrag(nodeId),
onDragUpdate: (details) => controller.moveNodeDrag(details.delta),
onDragEnd: (_) => controller.endNodeDrag(),
// ... other callbacks
)
Implementation
final DragSession Function()? createSession;