TreeView class
The TreeView
control enables a hierarchical list with expanding and
collapsing nodes that contain nested items. It can be used to illustrate a
folder structure or nested relationships in your UI.
The tree view uses a combination of indentation and icons to represent the nested relationship between parent nodes and child nodes. Collapsed items use a chevron pointing to the right, and expanded nodes use a chevron pointing down.
You can include an icon in the TreeViewItem template to represent items. For example, if you show a file system hierarchy, you could use folder icons for the parent items and file icons for the leaf items.
See also:
- docs.microsoft.com/en-us/windows/apps/design/controls/tree-view
- TreeViewItem, used to render the tiles
- Checkbox, used on multiple selection mode
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TreeView
- Available Extensions
Constructors
-
TreeView({Key? key, required List<
TreeViewItem> items, TreeViewSelectionMode selectionMode = TreeViewSelectionMode.none, TreeViewSelectionChangedCallback? onSelectionChanged, TreeViewItemInvoked? onItemInvoked, TreeViewItemOnExpandToggle? onItemExpandToggle, TreeViewItemOnSecondaryTap? onSecondaryTap, TreeViewItemGesturesCallback? gesturesBuilder, Widget loadingWidget = kTreeViewLoadingIndicator, bool shrinkWrap = true, bool? scrollPrimary, ScrollController? scrollController, double? cacheExtent, double? itemExtent, bool addRepaintBoundaries = true, bool usePrototypeItem = false, bool narrowSpacing = false, bool includePartiallySelectedItems = false, bool deselectParentWhenChildrenDeselected = true}) -
Creates a tree view.
const
Properties
- addRepaintBoundaries → bool
-
Whether to wrap each child in a RepaintBoundary.
final
- cacheExtent → double?
-
The viewport has an area before and after the visible area to cache items
that are about to become visible when the user scrolls.
final
- deselectParentWhenChildrenDeselected → bool
-
If selectionMode is TreeViewSelectionMode.multiple, indicates if
a parent will automatically be deselected when all of its children
are deselected. If you disable this behavior, also consider if you
want to set includePartiallySelectedItems to true.
final
- gesturesBuilder → TreeViewItemGesturesCallback?
-
A callback that receives a notification that the gestures for an item
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- includePartiallySelectedItems → bool
-
If true, will include items that are in an indeterminute (partially
selected) state in the list of selected items in the
onSelectionChanged callback.
final
- itemExtent → double?
-
If non-null, forces the children to have the given extent in the scroll
direction.
final
-
items
→ List<
TreeViewItem> -
The items of the tree view.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingWidget → Widget
-
A widget to be shown when a node is loading. Only used if
TreeViewItem.loadingWidget is null.
final
- narrowSpacing → bool
-
Whether or not to have narrow spacing between the contents of each item.
final
- onItemExpandToggle → TreeViewItemOnExpandToggle?
-
Called when an item's expand state is toggled.
final
- onItemInvoked → TreeViewItemInvoked?
-
Called when an item is invoked
final
- onSecondaryTap → TreeViewItemOnSecondaryTap?
-
A tap with a secondary button has occurred.
final
- onSelectionChanged → TreeViewSelectionChangedCallback?
-
Called when the selection changes. The items that are currently
selected will be passed to the callback. This could be empty
if nothing is now selected. If TreeView.selectionMode is
TreeViewSelectionMode.single then it will contain exactly
zero or one items.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
An object that can be used to control the position to which this scroll
view is scrolled.
final
- scrollPrimary → bool?
-
Whether this is the primary scroll view associated with the parent
PrimaryScrollController.
final
- selectionMode → TreeViewSelectionMode
-
The current selection mode.
final
- shrinkWrap → bool
-
Whether the extent of the scroll view in the
scrollDirection
should be determined by the contents being viewed.final - usePrototypeItem → bool
-
Whether or not to give the internal ListView a prototype item based on
the first item in the tree view. Set this to true to allow the ListView to
more efficiently calculate the maximum scrolling extent, and it will force
the vertical size of each item to be the same size as the first item in
the tree view.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TreeView> -
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.
override
-
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