TreeViewController class

A simple Controller for managing the nodes that compose TreeView.

This class was extracted from TreeView for use cases where you need to toggle/find a node from above of TreeView in the widget tree.

This controller should have at most 1 listener (the TreeView itself) that removes itself when disposed, but you might as well call dispose just to be safe, as this is a ChangeNotifier after all.

Mixed-in types

Constructors

TreeViewController({required TreeNode rootNode, bool useBinarySearch = false, void onAboutToExpand(TreeNode node)?})
Creates a TreeViewController.

Properties

expandedNodes UnmodifiableListView<String>
The list of node id's that are currently expanded in the TreeView.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
onAboutToExpand → void Function(TreeNode node)?
This method is called right before a TreeNode is expanded.
final
rootNode TreeNode
The TreeNode that will store all top level nodes.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useBinarySearch bool
Whether TreeViewControllerBase.indexOf should use flutter's binarySearch instead of List.indexOf when looking for the index of a node.
finalinherited
visibleNodes UnmodifiableListView<TreeNode>
The list of TreeNode's that are currently visible in the TreeView.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
collapseAll() → void
Collapses all nodes. Only the children of TreeViewController.rootNode will be visible.
collapseNode(TreeNode node) → void
Collapses node and it's subtree.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
expandAll() → void
Expands every node in the tree.
expandNode(TreeNode node) → void
Expands node.
expandSubtree(TreeNode node) → void
Expands node and every descendant node.
expandUntil(TreeNode node) → void
Expands every node within the path from root to node.
find(String id) TreeNode?
Starting from rootNode, searches the subtree looking for a node id that match id, returns null if no node was found with the given id.
indexOf(TreeNode node) int
Returns the index of node in TreeViewControllerBase.visibleNodes, -1 if not present.
inherited
isExpanded(String id) bool
Verifies if the TreeNode with id is expanded.
inherited
isVisible(String id) bool
Verifies if the TreeNode with id is visible.
inherited
nodeAt(int index) TreeNode
Returns the node at index of visibleNodes.
inherited
nodeRefreshed(String id) → void
Removes id from the map of nodes that needs refresh.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
refreshNode(TreeNode node, {bool keepExpandedNodes = false}) → void
Refreshes node's subtree.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reset({bool keepExpandedNodes = false}) → void
Resets the entire state of this controller and populates visibleNodes with the children of rootNode.
shouldRefresh(String id) bool
Checks if the TreeNode with id needs to be refreshed (update lines, ...).
toggleExpanded(TreeNode node) → void
Toggles the expansion of node to the opposite state.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited