TreeReorderController<TKey, TData> class
Controls a drag-and-drop reorder over a TreeController.
Owns an autoscroll Ticker for edge-zone scrolling. 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 (like the built-in drop indicator) subscribe here instead of polling per-frame.
- Inheritance
-
- Object
- ChangeNotifier
- TreeReorderController
Constructors
-
TreeReorderController({required TreeController<
TKey, TData> treeController, required TickerProvider vsync, bool canReorder(TKey key)?, bool canAcceptDrop({int? index, required TKey movingKey, TKey? newParent})?, Duration slideDuration = const Duration(milliseconds: 220), Curve slideCurve = Curves.easeOutCubic, double autoScrollEdgeZone = 48.0, double autoScrollMaxVelocity = 1200.0})
Properties
- 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.
final
- autoScrollMaxVelocity → double
-
Peak autoscroll velocity in logical pixels per second.
final
- 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.no setter - draggedKey → TKey?
-
The currently-dragged key, or
nullif no drag is active.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
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- slideCurve → Curve
-
Curve of the FLIP slide animation.
final
- slideDuration → Duration
-
Duration of the FLIP slide animation on commit.
final
-
treeController
→ TreeController<
TKey, TData> -
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 -
Releases the autoscroll ticker. Call from the owning widget's
dispose.override -
endDrag(
) → Future< void> - Commits the drop: mutates treeController (via TreeController.moveNode, TreeController.reorderChildren, or TreeController.reorderRoots) and starts the FLIP slide animation to interpolate old → new positions.
-
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 RenderSliverTree< TKey, TData> renderObject, required ScrollableState scrollable, required double indentPerDepth, required Offset pointerGlobal}) → void -
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