TreeDragTarget<T extends Object> class

A DragTarget wrapper that provides some additional tree view capabilities like auto toggle expansion on hover.

Usage:

@override
Widget build(BuildContext context) {
  return TreeDragTarget<Node>(
    // The node that will receive the drop from dragging nodes.
    node: entry.node,

    // The following callback is used to apply the changes to the tree
    // structure when the dragging node is accepted by this target node.
    onNodeAccepted: (TreeDragAndDropDetails<Node> details) { },

    // If details is provided, there's a [TreeDraggable] currently hovering
    // this drag target, add some decoration to the tree node tile to show
    // to the user what will happen when they drop the node in this target.
    builder: (BuildContext context, TreeDragAndDropDetails<Node>? details) {
      if (details != null) {
        return MyDecoratedTreeNodeTile();
      }
      return MyTreeNodeTile();
    },
  ),
}
Inheritance

Constructors

TreeDragTarget({Key? key, required T node, required TreeDraggableBuilder<T> builder, required TreeDragTargetNodeAccepted<T> onNodeAccepted, DragTargetWillAcceptWithDetails<T>? onWillAcceptWithDetails, bool toggleExpansionOnHover = true, Duration toggleExpansionDelay = const Duration(seconds: 1), bool canToggleExpansion = true, @Deprecated('Use onWillAcceptWithDetails instead.') DragTargetWillAccept<T>? onWillAccept, @Deprecated('Use onAcceptWithDetails instead.') DragTargetAccept<T>? onAccept, DragTargetAcceptWithDetails<T>? onAcceptWithDetails, DragTargetLeave<T>? onLeave, DragTargetMove<T>? onMove, HitTestBehavior hitTestBehavior = HitTestBehavior.translucent})
Creates a TreeDragTarget.
const

Properties

builder TreeDraggableBuilder<T>
Called to build the contents of this widget.
final
canToggleExpansion bool
Whether node can have its expansion state toggled when it is being hovered by another dragging tree node.
final
hashCode int
The hash code for this object.
no setterinherited
hitTestBehavior HitTestBehavior
How to behave during hit testing.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
node → T
The tree node that is going to receive the drop of a TreeDraggable.
final
onAccept DragTargetAccept<T>?
Called when an acceptable piece of data was dropped over this drag target.
final
onAcceptWithDetails DragTargetAcceptWithDetails<T>?
Called when an acceptable piece of data was dropped over this drag target. It will not be called if data is null.
final
onLeave DragTargetLeave<T>?
Called when a given piece of data being dragged over this target leaves the target.
final
onMove DragTargetMove<T>?
Called when a Draggable moves within this DragTarget.
final
onNodeAccepted TreeDragTargetNodeAccepted<T>
Called when a dragging node was successfully dropped onto this drag target.
final
onWillAccept DragTargetWillAccept<T>?
Called to determine whether this widget is interested in receiving a given piece of data being dragged over this drag target.
final
onWillAcceptWithDetails DragTargetWillAcceptWithDetails<T>?
Called to determine whether this widget is interested in receiving a given piece of data being dragged over this drag target.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toggleExpansionDelay Duration
The Duration to wait before automatically toggling the expansion state of node when it is being hovered by another dragging tree node.
final
toggleExpansionOnHover bool
Whether to automatically toggle the expansion state of node when it is being hovered by another dragging tree node.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TreeDragTarget<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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