SyncedSliverTree<TKey, TItem> class
A sliver widget that declaratively displays a tree and animates changes.
Example:
SyncedSliverTree<String, Folder>(
tree: <SyncedTreeNode<String, Folder>>[
SyncedTreeNode<String, Folder>(
key: rootFolder.id,
data: rootFolder,
children: <SyncedTreeNode<String, Folder>>[
SyncedTreeNode<String, Folder>(
key: childFolder.id,
data: childFolder,
),
],
),
],
itemBuilder: (context, node) {
return ListTile(
title: Text(node.item.name),
leading: node.hasChildren
? IconButton(
icon: Icon(
node.isExpanded
? Icons.expand_more
: Icons.chevron_right,
),
onPressed: node.toggle,
)
: null,
);
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SyncedSliverTree
Constructors
-
SyncedSliverTree({required Iterable<
SyncedTreeNode< tree, required TreeItemBuilder<TKey, TItem> >TKey, TItem> itemBuilder, bool preserveExpansion = true, bool initiallyExpanded = true, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, double indentWidth = 0.0, int maxStickyDepth = 0, Key? key}) -
Creates a synced sliver tree from an immutable nested tree.
const
-
SyncedSliverTree.flat({required Iterable<
TItem> items, required TKey keyOf(TItem item), required TKey? parentOf(TItem item), required TreeItemBuilder<TKey, TItem> itemBuilder, bool preserveExpansion = true, bool initiallyExpanded = true, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, double indentWidth = 0.0, int maxStickyDepth = 0, Key? key}) -
Creates a synced sliver tree from flat items with optional parent keys.
const
-
SyncedSliverTree.hierarchy({required Iterable<
TItem> roots, required TKey keyOf(TItem item), required Iterable<TItem> childrenOf(TItem item), required TreeItemBuilder<TKey, TItem> itemBuilder, bool preserveExpansion = true, bool initiallyExpanded = true, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, double indentWidth = 0.0, int maxStickyDepth = 0, Key? key}) -
Creates a synced sliver tree from nested domain objects.
const
-
SyncedSliverTree.nodes({required Iterable<
TreeNode< roots, required Iterable<TKey, TItem> >TreeNode< childrenOf(TKey key), required TreeItemBuilder<TKey, TItem> >TKey, TItem> itemBuilder, bool preserveExpansion = true, bool initiallyExpanded = true, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, double indentWidth = 0.0, int maxStickyDepth = 0, Key? key}) -
Creates a synced sliver tree from existing TreeNode roots plus
a
childrenOfcallback.const -
SyncedSliverTree.snapshot({required TreeSnapshot<
TKey, TItem> snapshot, required TreeItemBuilder<TKey, TItem> itemBuilder, bool preserveExpansion = true, bool initiallyExpanded = true, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, double indentWidth = 0.0, int maxStickyDepth = 0, Key? key}) -
Creates a synced sliver tree from a precomputed validated snapshot.
const
Properties
- animationCurve → Curve
-
Curve for animations.
final
- animationDuration → Duration
-
Duration for expand/collapse and add/remove animations.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- indentWidth → double
-
Horizontal indent per depth level in logical pixels.
final
- initiallyExpanded → bool
-
Whether all nodes should be expanded when the tree is first created.
final
-
itemBuilder
→ TreeItemBuilder<
TKey, TItem> -
Builds the widget for each visible node.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxStickyDepth → int
-
How many depth levels of headers should stick to the top.
final
- preserveExpansion → bool
-
Whether to preserve expansion state when nodes are removed and re-added.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SyncedSliverTree< TKey, TItem> > -
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, int wrapWidth = 65}) → 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