TreeViewItem.from constructor
TreeViewItem.from(
- TreeViewItem source
Deep copy constructor that can be used to copy an item and all of its child items. Useful if you want to have multiple trees with the same items, but with different UX states (e.g., selection, visibility, etc.).
Implementation
factory TreeViewItem.from(TreeViewItem source) {
final newItem = TreeViewItem(
key: source.key,
leading: source.leading,
content: source.content,
value: source.value,
children: source.children.map(TreeViewItem.from).toList(),
collapsable: source.collapsable,
expanded: source.expanded,
selected: source.selected,
onInvoked: source.onInvoked,
onExpandToggle: source.onExpandToggle,
backgroundColor: source.backgroundColor,
autofocus: source.autofocus,
focusNode: source.focusNode,
semanticLabel: source.semanticLabel,
loadingWidget: source.loadingWidget,
lazy: source.lazy,
);
for (final c in newItem.children) {
c._parent = newItem;
}
return newItem;
}