TreeView<Data, Tree extends ITreeNode<Data> > class
final
The TreeView allows to visually display a tree data structure in a linear list which animates the node addition, removal, changes and expansion/collapse of the node.
The TreeView is based on the AnimatedList, so it can be used as a replacement of AnimatedList.
The default TreeView.simple uses a TreeNode internally, which is based on the Map data structure for maintaining the children states. The TreeNode does not allow insertion and removal of items at index positions. This allows for more efficient insertion and retrieval of items at child nodes, as child items can be readily accessed using the map keys.
The complexity for accessing child nodes in TreeView is simply O(node_level). e.g. for path './.level1/level2', complexity is simply O(2).
See also: For a TreeView that supports Slivers, that can used with a CustomScrollView look into the SliverTreeView.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TreeView
Properties
-
animation
→ Animation<
double> ? -
An optional animation for AnimatedList. If no animation is provided, AnimatedList falls back on its default.
finalinherited
-
builder
→ TreeNodeWidgetBuilder<
Tree> -
The
builder
function that is provided to the item builderfinalinherited - expansionBehavior → ExpansionBehavior
-
The ExpansionBehavior provides control over the behavior of the node
when it is expanded.
finalinherited
- expansionIndicatorBuilder → ExpansionIndicatorBuilder
-
Builder function for building the expansion indicator.
It takes a
Tree
and builds the expansion indicator based on whether the tree node is expanded or not.finalinherited - focusToNewNode → bool
-
Should the tree move the focus to a new (added or inserted) node.
It is true by default.
If false, the TreeView will not scroll to the new nodes when they are
added or inserted to the tree.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- indentation → Indentation
-
This is the indentation applied to the start of an item. Indentation.width
will be multiplied by INode.level before being applied.
** e.g. if the node level is 2 and Indentation.width is 8, then the start
padding applied to an item will be 2*8 = 16
finalinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onItemTap
→ ValueSetter<
Tree> ? -
An optional callback that can be used to handle any action when an item is
tapped or clicked
finalinherited
-
onTreeReady
→ TreeReadyCallback<
Data, Tree> ? -
Callback to get the TreeViewController when the TreeView is ready
finalinherited
- padding → EdgeInsetsGeometry?
-
The amount of space by which to inset the children.
finalinherited
- physics → ScrollPhysics?
-
An object that can be used to control the position to which this scroll
view is scrolled.
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
- scrollController → AutoScrollController?
-
An optional
scrollController
that provides more granular control over scrolling behaviorfinalinherited - showRootNode → bool
-
Flag to show the Root Node in the TreeView. Root Node is always the first
item in the TreeView. If it is set to
false
then the Root Node will not be displayed, rather the first child of the RootNode will be the first item in the TreeListfinalinherited - shrinkWrap → bool
-
Whether the extent of the scroll view in the
scrollDirection
should be determined by the contents being viewed. This is passed directly to the AnimatedList's shrinkWrap attribute For more information see the AnimatedList.shrinkWrapfinal -
tree
→ ITreeNode<
Data> -
The rootNode of the
tree
. If thetree
is updated using setState or any other state management tool, then a TreeDiff is performed to get all the nodes that have been modified between the old and new trees. TheTreeDiffUpdate
result is then used to apply the changes in the new tree to the old tree.finalinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
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 Methods
-
indexed<
Data> ({Key? key, required TreeNodeWidgetBuilder< IndexedTreeNode< builder, required IndexedTreeNode<Data> >Data> tree, ExpansionBehavior expansionBehavior = ExpansionBehavior.none, Indentation? indentation, AutoScrollController? scrollController, ExpansionIndicatorBuilder? expansionIndicatorBuilder, ValueSetter<IndexedTreeNode< ? onItemTap, bool? primary, ScrollPhysics? physics, EdgeInsetsGeometry? padding, bool shrinkWrap = false, bool showRootNode = true, bool focusToNewNode = true, TreeReadyCallback<Data> >Data, IndexedTreeNode< ? onTreeReady, Animation<Data> >double> ? animation}) → TreeView<Data, IndexedTreeNode< Data> > - The alternate implementation of TreeView uses an IndexedNode internally, which is based on the List data structure for maintaining the children states. The IndexedNode allows indexed based operations like insertion and removal of items at index positions. This allows for movement, addition and removal of child nodes based on indices.
-
indexTyped<
Data, Tree extends IndexedTreeNode< (Data> >{Key? key, required TreeNodeWidgetBuilder< Tree> builder, required Tree tree, ExpansionBehavior expansionBehavior = ExpansionBehavior.none, Indentation? indentation, AutoScrollController? scrollController, ExpansionIndicatorBuilder? expansionIndicatorBuilder, ValueSetter<Tree> ? onItemTap, bool? primary, ScrollPhysics? physics, EdgeInsetsGeometry? padding, bool shrinkWrap = false, bool showRootNode = true, bool focusToNewNode = true, TreeReadyCallback<Data, Tree> ? onTreeReady, Animation<double> ? animation}) → TreeView<Data, Tree> -
Use the typed constructor if you are extending the IndexedTreeNode instead
of directly wrapping the data in the IndexedTreeNode.
Using the TreeView.indexTyped allows the
builder
to return the correctly typedTree
object. -
simple<
Data> ({Key? key, required TreeNodeWidgetBuilder< TreeNode< builder, required TreeNode<Data> >Data> tree, ExpansionBehavior expansionBehavior = ExpansionBehavior.none, Indentation? indentation, AutoScrollController? scrollController, ExpansionIndicatorBuilder? expansionIndicatorBuilder, ValueSetter<TreeNode< ? onItemTap, bool? primary, ScrollPhysics? physics, EdgeInsetsGeometry? padding, bool shrinkWrap = false, bool showRootNode = true, bool focusToNewNode = true, TreeReadyCallback<Data> >Data, TreeNode< ? onTreeReady, Animation<Data> >double> ? animation}) → TreeView<Data, TreeNode< Data> > - The default implementation of TreeView that uses a TreeNode internally, which is based on the Map data structure for maintaining the children states. The TreeNode does not allow insertion and removal of items at index positions. This allows for more efficient insertion and retrieval of items at child nodes, as child items can be readily accessed using the map keys.
-
simpleTyped<
Data, Tree extends TreeNode< (Data> >{Key? key, required TreeNodeWidgetBuilder< Tree> builder, required Tree tree, ExpansionBehavior expansionBehavior = ExpansionBehavior.none, Indentation? indentation, AutoScrollController? scrollController, ExpansionIndicatorBuilder? expansionIndicatorBuilder, ValueSetter<Tree> ? onItemTap, bool? primary, ScrollPhysics? physics, EdgeInsetsGeometry? padding, bool shrinkWrap = false, bool showRootNode = true, bool focusToNewNode = true, TreeReadyCallback<Data, Tree> ? onTreeReady, Animation<double> ? animation}) → TreeView<Data, Tree> -
Use the typed constructor if you are extending the TreeNode instead of
directly wrapping the data in the TreeNode. Using the TreeView.simpleTyped
allows the
builder
to return the correctly typedTree
object.