TreeReorderController<TKey> class

Controls a drag-and-drop reorder over a TreeController.

Not usable with a comparator-based controller (auto-sort would override user order); the constructor throws ArgumentError in that case.

Extends ChangeNotifier: listeners are notified whenever currentTarget changes or the drag session begins/ends. Consumers that need to repaint per-pointer-move subscribe here instead of polling per-frame; the per-move pointerPosition channel exists for those that must follow the pointer itself.

Inheritance

Constructors

TreeReorderController({required TreeController<TKey, Object?> treeController, required TickerProvider vsync, bool canReorder(TKey key)?, bool canAcceptDrop({int? index, required TKey movingKey, TKey? newParent})?, void onReorder(TKey key, TKey? newParent, int index)?, double autoScrollEdgeZone = 48.0, double autoScrollMaxVelocity = 1200.0, Duration? autoExpandDelay = const Duration(milliseconds: 700)})

Properties

autoExpandDelay ↔ Duration?
How long the pointer must dwell on an into target that is collapsed (and has live children to reveal) before the target auto-expands, the conventional hover-to-open tree affordance.
getter/setter pair
autoScrollEdgeZone ↔ double
Height in pixels from each viewport edge within which the pointer triggers autoscroll. Velocity ramps linearly from 0 at the zone's inner edge to autoScrollMaxVelocity at the viewport edge.
getter/setter pair
autoScrollMaxVelocity ↔ double
Peak autoscroll velocity in logical pixels per second.
getter/setter pair
canAcceptDrop → bool Function({int? index, required TKey movingKey, TKey? newParent})?
If set, rejected drop targets are filtered out. Receives the dragged key, the candidate new parent, and the final-list index.
final
canReorder → bool Function(TKey key)?
If set, rows for which this returns false cannot be dragged.
final
currentTarget → TreeDropTarget<TKey>?
The current drop target, or null if the pointer is outside any row or every candidate slot is a cycle.
no setter
draggedKey → TKey?
The currently-dragged key, or null if no drag is active.
no setter
dragGeneration → int
Monotonically increasing identity for drag sessions.
no setter
dragProxyGeometry → ({double grabDy, double rowExtent})?
The active session's grab geometry: the pointer's dy within the dragged row at start, and that row's extent. null when idle. Presentation consumers position the proxy at pointer - grabDy.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isDragging → bool
Whether a drag is currently in flight.
no setter
onReorder → void Function(TKey key, TKey? newParent, int index)?
Reports every committed reorder, whatever initiated it: a pointer drop, moveTo, or one of the four semantic moves.
final
pointerPosition → ValueListenable<Offset?>
Per-pointer-move channel: the latest global pointer position, null when idle. A drag proxy must reposition on EVERY move, whereas the ChangeNotifier channel deliberately coalesces to semantic target changes: two channels, two contracts.
no setter
renderPort → ReorderRenderPort<TKey>?
The render port of the active drag session, or null when idle.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
treeController → TreeController<TKey, Object?>
The tree controller to mutate on drop.
final

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
cancelDrag() → void
Aborts the current drag without mutating the tree.
dispose() → void
Tears down any active session (its collaborators own their tickers and timers). Call from the owning widget's dispose.
override
endDrag() → void
Commits the drop: mutates treeController (via TreeController.moveNode, TreeController.reorderChildren, or TreeController.reorderRoots) and starts the FLIP slide animation to interpolate old to new positions.
moveDown(TKey key) → bool
Moves key one position later among its live siblings. See moveUp.
moveIntoPrevious(TKey key) → bool
Moves key in as the last child of its previous live sibling. See moveUp.
moveOut(TKey key) → bool
Moves key out of its parent, to sit directly after that parent among its grandparent's children. See moveUp.
moveTo(TKey key, TKey? newParent, {required int index, bool animate = true}) → bool
Commits a programmatic move of key under newParent at index, exactly as a pointer drop would: same mutation choice, same live-space final-list index convention, same onReorder report.
moveUp(TKey key) → bool
Moves key one position earlier among its live siblings.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
startDrag({required TKey key, required ReorderRenderPort<TKey> renderPort, required ScrollableState scrollable, required Offset pointerGlobal, int depthForPointerX(double sliverLocalX)?, double proxyCrossOffset()?, bool makeRoom = false, bool settleFromRelease = false}) → bool
Begins a drag session for key.
toString() → String
A string representation of this object.
inherited
updateDrag(Offset pointerGlobal) → void
Updates the pointer position. Re-resolves the drop target and starts / stops the autoscroll ticker as needed.

Operators

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