TreeSliverController class

Enables control over the TreeSliverNodes of a TreeSliver.

It can be useful to expand or collapse nodes of the tree programmatically, for example to reconfigure an existing node based on a system event. To do so, create a TreeSliver with a TreeSliverController that's owned by a stateful widget or look up the tree's automatically created TreeSliverController with TreeSliverController.of

The controller's methods to expand or collapse nodes cause the the TreeSliver to rebuild, so they may not be called from a build method.

Constructors

TreeSliverController()
Create a controller to be used with TreeSliver.controller.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

collapseAll() → void
Closes all parent TreeSliverNodes in the tree.
collapseNode(TreeSliverNode<Object?> node) → void
Collapses the TreeSliverNode that was built with this controller.
expandAll() → void
Expands all parent TreeSliverNodes in the tree.
expandNode(TreeSliverNode<Object?> node) → void
Expands the TreeSliverNode that was built with this controller.
getActiveIndexFor(TreeSliverNode<Object?> node) int?
Returns the current row index of the given TreeSliverNode.
getNodeFor(Object? content) TreeSliverNode<Object?>?
Returns the TreeSliverNode containing the associated content, if it exists.
isActive(TreeSliverNode<Object?> node) bool
Whether or not the given TreeSliverNode is enclosed within its parent TreeSliverNode.
isExpanded(TreeSliverNode<Object?> node) bool
Whether the given TreeSliverNode built with this controller is in an expanded state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toggleNode(TreeSliverNode<Object?> node) → void
Switches the given TreeSliverNodes expanded state.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

maybeOf(BuildContext context) TreeSliverController?
Finds the TreeSliver from the closest instance of this class that encloses the given context and returns its TreeSliverController.
of(BuildContext context) TreeSliverController
Finds the TreeSliverController for the closest TreeSliver instance that encloses the given context.