ArcoTree class

树形控件,还原官方 Tree。

结构对应官方 tsx:arco-tree → .arco-tree-node(-indent 缩进块 → -switcher 展开箭头 → Checkbox(可选)→ -title)逐行渲染; 子树的显示条件是所有祖先节点都处于展开状态(官方 visibleKeys 语义),展开收起以 200ms cubic-bezier(0.34,0.69,0.1,1) 的高度过渡 呈现(官方 tree-slide-expand + .arco-tree-node-list{overflow:hidden})。

几何与配色对照 arco.css:

  • .arco-tree-node { padding-left: 2px; line-height: 1.5715 }, 行高按尺寸 mini/small/default/large 为 24/28/32/36(标题上下 padding 2/3/5/7 + 行盒;mini 标题 12px/1.667)。
  • .arco-tree-node-indent-block { width: 12px; margin-right: 10px } (show-line 14px),.arco-tree-node-switcher { width: 12px/14px; margin-right: 10px; height: 行高 }。
  • .arco-tree-node-title { font-size: 14px; padding: 5px 4px; margin-left: -4px; border-radius: small },hover 背景 fill-2、 选中文字 primary-6、禁用文字 text-4(选中+禁用 primary-light-3)。
  • show-line:缩进块居中 1px neutral-3 竖线(上下各越出 (行高-22)/2 与相邻行相连),非末尾叶子在箭头位画垂直肘线; 分支节点为 14×14 fill-2 的 plus/minus 图标,叶子为 IconFile; 非 show-line 分支为 caret(收起旋转 -90°,200ms 过渡)。
Inheritance

Constructors

ArcoTree({Key? key, List<ArcoTreeNodeData> nodes = const [], ArcoTreeSize size = ArcoTreeSize.defaultSize, bool blockNode = false, bool autoExpandParent = true, bool multiple = false, bool checkable = false, bool selectable = true, bool checkStrictly = false, ArcoCheckedStrategy checkedStrategy = ArcoCheckedStrategy.all, bool showLine = false, bool animation = true, Set<ArcoTreeActionOnNodeClick> actionOnClick = const <ArcoTreeActionOnNodeClick>{ArcoTreeActionOnNodeClick.select}, List<String>? selectedKeys, List<String> defaultSelectedKeys = const [], List<String>? checkedKeys, List<String> defaultCheckedKeys = const [], List<String>? halfCheckedKeys, List<String>? expandedKeys, List<String>? defaultExpandedKeys, ArcoTreeIcons? icons, Future<void> loadMore(ArcoTreeNodeData node)?, void onSelect(List<String> selectedKeys, ArcoTreeSelectExtra extra)?, void onCheck(List<String> checkedKeys, ArcoTreeCheckExtra extra)?, void onExpand(List<String> expandedKeys, ArcoTreeExpandExtra extra)?, Widget renderTitle(ArcoTreeNodeData node)?, bool filterNode(ArcoTreeNodeData node)?, bool draggable = false, bool allowDrop({required ArcoTreeNodeData dragNode, required ArcoTreeNodeData dropNode, required int dropPosition})?, void onDragStart(ArcoTreeNodeData node)?, void onDragEnd(ArcoTreeNodeData node)?, void onDragOver(ArcoTreeNodeData node)?, void onDragLeave(ArcoTreeNodeData node)?, void onDrop({required ArcoTreeNodeData dragNode, required ArcoTreeNodeData dropNode, required int dropPosition})?})
创建树。
const

Properties

actionOnClick → Set<ArcoTreeActionOnNodeClick>
点击节点标题时的行为集合(官方 actionOnClick)。
final
allowDrop → bool Function({required ArcoTreeNodeData dragNode, required ArcoTreeNodeData dropNode, required int dropPosition})?
是否允许放置(官方 allowDrop):返回 false 时该位置不显示放置 指示且不触发 onDrop。dropPosition:-1 前插入 / 0 放入 / 1 后插入。
final
animation → bool
是否开启展开收起的高度过渡(官方 animation,默认 true)。
final
autoExpandParent → bool
是否自动展开父节点(官方 autoExpandParent,默认 true:未指定展开 集合时展开全部父节点;指定 defaultExpandedKeys 时补齐其祖先)。
final
blockNode → bool
节点标题占据一行(官方 blockNode)。
final
checkable → bool
是否在节点前添加选框(官方 checkable)。
final
checkedKeys → List<String>?
受控勾选的节点 key(官方 checkedKeys)。
final
checkedStrategy → ArcoCheckedStrategy
勾选回填方式(官方 checkedStrategy,默认 all)。
final
checkStrictly → bool
是否取消父子勾选关联(官方 checkStrictly)。
final
defaultCheckedKeys → List<String>
默认勾选的节点 key(官方 defaultCheckedKeys)。
final
defaultExpandedKeys → List<String>?
默认展开的节点 key(官方 defaultExpandedKeys);缺省时展开全部 父节点(官方 autoExpandParent 语义)。
final
defaultSelectedKeys → List<String>
默认选中的节点 key(官方 defaultSelectedKeys)。
final
draggable → bool
是否可拖拽(官方 draggable);节点可用 ArcoTreeNodeData.draggable 覆盖。
final
expandedKeys → List<String>?
受控展开的节点 key(官方 expandedKeys)。
final
filterNode → bool Function(ArcoTreeNodeData node)?
节点过滤(官方 filterNode):返回 true 的节点及其祖先可见, 其余隐藏;为 null 时全部可见。供 ArcoTreeSelect 搜索使用。
final
halfCheckedKeys → List<String>?
半选节点 key。仅在 checkable 且 checkStrictly 时生效 (官方 halfCheckedKeys)。
final
hashCode → int
The hash code for this object.
no setterinherited
icons → ArcoTreeIcons?
定制展开 / 加载图标(官方 icons)。
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadMore → Future<void> Function(ArcoTreeNodeData node)?
异步加载子数据的回调(官方 loadMore);节点显式 isLeaf: false 且无子节点时点击展开触发。
final
multiple → bool
是否支持多选(官方 multiple)。
final
nodes → List<ArcoTreeNodeData>
树数据(官方 treeData)。
final
onCheck → void Function(List<String> checkedKeys, ArcoTreeCheckExtra extra)?
点击树节点复选框的回调(官方 onCheck)。
final
onDragEnd → void Function(ArcoTreeNodeData node)?
节点拖拽结束的回调(官方 onDragEnd)。
final
onDragLeave → void Function(ArcoTreeNodeData node)?
拖拽离开节点的回调(官方 onDragLeave)。
final
onDragOver → void Function(ArcoTreeNodeData node)?
节点被拖至其上方时的回调(官方 onDragOver)。
final
onDragStart → void Function(ArcoTreeNodeData node)?
节点开始拖拽的回调(官方 onDragStart)。
final
onDrop → void Function({required ArcoTreeNodeData dragNode, required ArcoTreeNodeData dropNode, required int dropPosition})?
在节点上释放的回调(官方 onDrop);拖到自身或自身后代上时不会 触发,数据重排由应用侧完成。
final
onExpand → void Function(List<String> expandedKeys, ArcoTreeExpandExtra extra)?
点击展开 / 收起的回调(官方 onExpand)。
final
onSelect → void Function(List<String> selectedKeys, ArcoTreeSelectExtra extra)?
点击树节点的回调(官方 onSelect)。
final
renderTitle → Widget Function(ArcoTreeNodeData node)?
自定义标题渲染(官方 renderTitle)。
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectable → bool
是否可以选择(官方 selectable,默认 true)。
final
selectedKeys → List<String>?
受控选中的节点 key(官方 selectedKeys)。
final
showLine → bool
是否展示连接线(官方 showLine)。
final
size → ArcoTreeSize
尺寸(官方 size)。
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ArcoTree>
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, int wrapWidth = 65}) → 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