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
-
- Object
- ChangeNotifier
- TreeReorderController
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
intotarget 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
nullif the pointer is outside any row or every candidate slot is a cycle.no setter - draggedKey → TKey?
-
The currently-dragged key, or
nullif 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.
nullwhen idle. Presentation consumers position the proxy atpointer - 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,
nullwhen 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
nullwhen 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
keyone position later among its live siblings. See moveUp. -
moveIntoPrevious(
TKey key) → bool -
Moves
keyin as the last child of its previous live sibling. See moveUp. -
moveOut(
TKey key) → bool -
Moves
keyout 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
keyundernewParentatindex, exactly as a pointer drop would: same mutation choice, same live-space final-list index convention, same onReorder report. -
moveUp(
TKey key) → bool -
Moves
keyone 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
-
notifyScrollableChanged(
) → void -
Re-points the live drag session's scroll subscription at the
scrollable's current
ScrollPosition. -
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