TreeNode<T> constructor

TreeNode<T>({
  1. required String label,
  2. bool isExpanded = false,
  3. bool isSelected = false,
  4. bool isPartiallySelected = false,
  5. IconData? icon,
  6. List<TreeNode<T>>? children,
  7. TreeNode<T>? parent,
  8. bool hidden = false,
  9. int originalIndex = 0,
  10. T? value,
})

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;
  }
}