TreeView<T> constructor
const
TreeView<T> ({
- Key? key,
- required List<
TreeNode< nodes,T> > - required Widget builder(
- BuildContext context,
- TreeItem<
T> node
- bool shrinkWrap = false,
- ScrollController? controller,
- BranchLine? branchLine,
- EdgeInsetsGeometry? padding,
- bool? expandIcon,
- bool? allowMultiSelect,
- FocusScopeNode? focusNode,
- TreeNodeSelectionChanged<
T> ? onSelectionChanged, - bool? recursiveSelection,
Creates a TreeView with hierarchical data display and interaction.
Configures a tree view widget that displays hierarchical data with support for expansion, selection, keyboard navigation, and visual styling.
Parameters:
key
(Key?): Widget identifier for the widget treenodes
(List<TreeNodebuilder
(Widget Function(BuildContext, TreeItemshrinkWrap
(bool, default: false): Whether to size to contentcontroller
(ScrollController?, optional): Scroll controller for the treebranchLine
(BranchLine?, optional): Style for connecting linespadding
(EdgeInsetsGeometry?, optional): Padding around contentexpandIcon
(bool?, optional): Whether to show expand/collapse iconsallowMultiSelect
(bool?, optional): Whether to allow multi-selectionfocusNode
(FocusScopeNode?, optional): Focus node for keyboard navigationonSelectionChanged
(TreeNodeSelectionChangedrecursiveSelection
(bool?, optional): Whether to select children recursively
Example:
TreeView<FileItem>(
nodes: fileTreeNodes,
allowMultiSelect: true,
recursiveSelection: true,
branchLine: BranchLine.path,
builder: (context, item) => ListTile(
leading: Icon(item.data.isDirectory ? Icons.folder : Icons.file_copy),
title: Text(item.data.name),
subtitle: Text(item.data.path),
),
onSelectionChanged: (selectedNodes, multiSelect, isSelected) {
handleSelectionChange(selectedNodes, isSelected);
},
)
Implementation
const TreeView({
super.key,
required this.nodes,
required this.builder,
this.shrinkWrap = false,
this.controller,
this.branchLine,
this.padding,
this.expandIcon,
this.allowMultiSelect,
this.focusNode,
this.onSelectionChanged,
this.recursiveSelection,
});