SliverAnimatedTree<T extends Object> class

A wrapper around SliverList that adds tree viewing capabilities with support for automatic expand and collapse animations.

Usage:

@override
Widget build(BuildContext context) {
  return CustomScrollView(
    slivers: [
      SliverAnimatedTree<Node>(
        controller: treeController,
        duration: const Duration(milliseconds, 300),
        curve: Curves.linear,
        maxNodesToShowWhenAnimating: 50,
        nodeBuilder: (BuildContext context, TreeEntry<Node> entry) {
          ...
        },
      ),
    ],
  );
}

This widget will listen to controller and rebuild the inner flat representation of the tree keeping a map of the expansion state of tree nodes to then check if the cached value is different from the current node expansion state when visiting that node during flattening and will mark it to be animated. When a node is marked to animate, its subtree won't be traversed during flattening to later on be rendered in the same list item of the subtree root's node widget. Once the animation completes, the node is removed from the set of animating nodes and the tree is flattened again so the animating subtree can go back to being one list item per node.

See also:

Inheritance

Constructors

SliverAnimatedTree({Key? key, required TreeController<T> controller, required TreeNodeBuilder<T> nodeBuilder, TreeTransitionBuilder transitionBuilder = defaultTreeTransitionBuilder, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.linear, int maxNodesToShowWhenAnimating = 50})
Creates a SliverAnimatedTree.
const

Properties

controller TreeController<T>
The object responsible for providing access to tree nodes and its states.
finalinherited
curve Curve
The default curve to use when animating the expand/collapse operations.
final
duration Duration
The default duration to use when animating the expand/collapse operations.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxNodesToShowWhenAnimating int
The amount of nodes that are going to be shown on an animating subtree.
final
nodeBuilder TreeNodeBuilder<T>
Callback used to map tree nodes into widgets.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
transitionBuilder TreeTransitionBuilder
A widget builder used to apply a transition to the expansion state changes of a node subtree when animations are enabled.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SliverAnimatedTree<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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