TreeView<T> class
A widget that displays TreeViewNodes that expand and collapse in a vertically and horizontally scrolling TreeViewport.
The type T
correlates to the type of TreeView and TreeViewNode,
representing the type of TreeViewNode.content.
The rows of the tree are laid out on demand by the TreeViewport's render object, using TreeView.treeNodeBuilder. This will only be called for the nodes that are visible, or within the TreeViewport.cacheExtent.
The TreeView.treeNodeBuilder returns the Widget that represents the given TreeViewNode.
The TreeView.treeRowBuilder returns a TreeRow, which provides details about the row such as the TreeRowExtent, as well as any TreeRow.recognizerFactories, TreeRowDecorations, and more.
Providing a TreeController
will enable querying and controlling the state
of nodes in the tree.
Each active node of the tree will have a TreeVicinity, representing the resolved row index of the node, based on what nodes are active, as well as the depth.
A TreeView only supports a vertical axis direction of AxisDirection.down and a horizontal axis direction of AxisDirection.right.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TreeView
Constructors
-
TreeView({Key? key, required List<
TreeViewNode< tree, TreeViewNodeBuilder<T> >T> treeNodeBuilder = TreeView.defaultTreeNodeBuilder, TreeViewRowBuilder<T> treeRowBuilder = TreeView.defaultTreeRowBuilder, TreeViewController? controller, TreeViewNodeCallback<T> ? onNodeToggle, AnimationStyle? toggleAnimationStyle, TreeViewIndentationType indentation = TreeViewIndentationType.standard, bool? primary, Axis mainAxis = Axis.vertical, ScrollableDetails verticalDetails = const ScrollableDetails.vertical(), ScrollableDetails horizontalDetails = const ScrollableDetails.horizontal(), double? cacheExtent, DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.none, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, Clip clipBehavior = Clip.hardEdge, bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true}) - Creates an instance of a TreeView for displaying TreeViewNodes that animate expanding and collapsing of nodes.
Properties
- addAutomaticKeepAlives → bool
-
Whether to wrap each row of the tree in an AutomaticKeepAlive.
final
- addRepaintBoundaries → bool
-
Whether to wrap each row in a RepaintBoundary.
final
- cacheExtent → double?
-
The TreeViewport has an area before and after the visible area to cache
rows that are about to become visible when the user scrolls.
final
- clipBehavior → Clip
-
The bounds of the TreeViewport will be clipped (or not) according to
this option.
final
- controller → TreeViewController?
-
If provided, the controller can be used to expand and collapse
TreeViewNodes, or lookup information about the current state of the
TreeView.
final
- diagonalDragBehavior → DiagonalDragBehavior
-
Whether scrolling gestures should lock to one axes, allow free movement
in both axes, or be evaluated on a weighted scale.
final
- dragStartBehavior → DragStartBehavior
-
Determines the way that drag start behavior is handled.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- horizontalDetails → ScrollableDetails
-
The configuration of the horizontal Scrollable.
final
- indentation → TreeViewIndentationType
-
The number of pixels children will be offset by in the cross axis based on
their TreeViewNode.depth.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardDismissBehavior → ScrollViewKeyboardDismissBehavior
-
ScrollViewKeyboardDismissBehavior the defines how this ScrollView will
dismiss the keyboard automatically.
final
- mainAxis → Axis
-
The main axis of the two.
final
-
onNodeToggle
→ TreeViewNodeCallback<
T> ? -
Called when a TreeViewNode is toggled to expand or collapse.
final
- primary → bool?
-
Whether this is the primary scroll view associated with the parent
PrimaryScrollController.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toggleAnimationStyle → AnimationStyle?
-
The default AnimationStyle for expanding and collapsing nodes in the
TreeView.
final
-
tree
→ List<
TreeViewNode< T> > -
The list of
TreeViewNode
s that may be displayed in the TreeView.final -
treeNodeBuilder
→ TreeViewNodeBuilder<
T> -
Called to build an entry of the TreeView for the given TreeViewNode.
final
-
treeRowBuilder
→ TreeViewRowBuilder<
T> -
Builds the TreeRow that describes the row for the provided
TreeViewNode.
final
- verticalDetails → ScrollableDetails
-
The configuration of the vertical Scrollable.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TreeView< 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
Static Properties
- defaultToggleAnimationStyle ↔ AnimationStyle
-
The default AnimationStyle used for node expand and collapse animations,
when one has not been provided in toggleAnimationStyle.
getter/setter pair
Static Methods
-
defaultTreeNodeBuilder(
BuildContext context, TreeViewNode< Object?> node, AnimationStyle toggleAnimationStyle) → Widget - Default builder for the widget representing a given TreeViewNode in the tree.
-
defaultTreeRowBuilder(
TreeViewNode< Object?> node) → TreeRow - Returns the fixed height, default TreeRow for rows in the tree, which is 40 pixels.
-
wrapChildToToggleNode(
{required TreeViewNode< Object?> node, required Widget child}) → Widget - A wrapper method for triggering the expansion or collapse of a TreeViewNode.
Constants
- defaultAnimationCurve → const Curve
- A default of Curves.linear, which is used in the tree's expanding and collapsing node animation.
- defaultAnimationDuration → const Duration
- A default Duration of 150 milliseconds, which is used in the tree's expanding and collapsing node animation.