TreeNode<T> constructor
TreeNode<T> ({})
Creates a TreeNode.
The label
parameter is required and specifies the text to display for this node.
The isExpanded
, isSelected
, isPartiallySelected
, and hidden
parameters
control the initial state of the node.
The icon
parameter specifies the icon to display next to the node.
The children
parameter is an optional list of child nodes.
The parent
parameter is the parent node of this node, if any.
The originalIndex
parameter is used to maintain the original order of nodes.
The value
parameter is an optional value associated with this node.
Implementation
TreeNode({
required this.label,
this.isExpanded = false,
this.isSelected = false,
this.isPartiallySelected = false,
this.icon, // 移除默认值,允许传入 null
List<TreeNode<T>>? children,
this.parent,
this.hidden = false,
this.originalIndex = 0,
this.value,
}) : children = children ?? [] {
for (var child in this.children) {
child.parent = this;
}
}