@@ -11,15 +11,13 @@ import 'tree_core.dart';
1111import 'tree_delegate.dart' ;
1212import 'tree_span.dart' ;
1313
14- // SHARED WITH FRAMEWORK - TreeViewNode (SliverTreeNode), TreeViewController (SliverTreeController)
15- // Should not deviate from the core components of the framework.
14+ // The classes in these files follow the same pattern as the one dimensional
15+ // sliver tree in the framework.
1616//
17- // These classes share the same surface as SliverTree in the framework since
18- // they are not currently available on the stable branch. After rolling to
19- // stable, these classes may be deprecated, or more likely made to be
20- // typedefs/subclasses of the framework core tree components. They could also
21- // live on if at a later date the 2D TreeView deviates or adds special features
22- // not relevant to the 1D sliver components of the framework.
17+ // After rolling to stable, these classes may be deprecated, or more likely
18+ // made to be typedefs/subclasses of the framework core tree components. They
19+ // could also live on if at a later date the 2D TreeView deviates or adds
20+ // special features not relevant to the 1D sliver components of the framework.
2321
2422const double _kDefaultRowExtent = 40.0 ;
2523
@@ -43,9 +41,6 @@ class TreeViewNode<T> {
4341 /// The subject matter of the node.
4442 ///
4543 /// Must correspond with the type of [TreeView] .
46- ///
47- /// The content is used to generate a unique [Key] in
48- /// [TreeView.defaultTreeNodeBuilder] for maintain animation performance.
4944 T get content => _content;
5045 final T _content;
5146
@@ -275,11 +270,14 @@ class TreeViewController {
275270 }
276271}
277272
278- // END of framework shared classes .
273+ // END of shared surfaces from the framework .
279274
280275/// A widget that displays [TreeViewNode] s that expand and collapse in a
281276/// vertically and horizontally scrolling [TreeViewport] .
282277///
278+ /// The type [T] correlates to the type of [TreeView] and [TreeViewNode] ,
279+ /// representing the type of [TreeViewNode.content] .
280+ ///
283281/// The rows of the tree are laid out on demand by the [TreeViewport] 's render
284282/// object, using [TreeView.treeNodeBuilder] . This will only be called for the
285283/// nodes that are visible, or within the [TreeViewport.cacheExtent] .
@@ -296,8 +294,7 @@ class TreeViewController {
296294///
297295/// Each active node of the tree will have a [TreeVicinity] , representing the
298296/// resolved row index of the node, based on what nodes are active, as well as
299- /// the depth. This vicinity is used to traverse the tree as indicated by
300- /// [traversalOrder] .
297+ /// the depth.
301298///
302299/// A [TreeView] only supports a vertical axis direction of
303300/// [AxisDirection.down] and a horizontal axis direction of
@@ -313,7 +310,6 @@ class TreeView<T> extends StatefulWidget {
313310 this .controller,
314311 this .onNodeToggle,
315312 this .toggleAnimationStyle,
316- this .traversalOrder = TreeViewTraversalOrder .depthFirst,
317313 this .indentation = TreeViewIndentationType .standard,
318314 this .primary,
319315 this .mainAxis = Axis .vertical,
@@ -378,15 +374,6 @@ class TreeView<T> extends StatefulWidget {
378374 /// To disable the tree animation, use [AnimationStyle.noAnimation] .
379375 final AnimationStyle ? toggleAnimationStyle;
380376
381- /// The order in which [TreeViewNode] s are visited.
382- ///
383- /// This value will influence [TreeViewport.mainAxis] so nodes are traversed
384- /// properly when they are converted to a [TreeVicinity] in the context of the
385- /// active nodes of the tree.
386- ///
387- /// Defaults to [TreeViewTraversalOrder.depthFirst] .
388- final TreeViewTraversalOrder traversalOrder;
389-
390377 /// The number of pixels children will be offset by in the cross axis based on
391378 /// their [TreeViewNode.depth] .
392379 ///
@@ -507,6 +494,13 @@ class TreeView<T> extends StatefulWidget {
507494 /// Defaults to true.
508495 final bool addRepaintBoundaries;
509496
497+ /// The default [AnimationStyle] used for node expand and collapse animations,
498+ /// when one has not been provided in [toggleAnimationStyle] .
499+ static AnimationStyle defaultToggleAnimationStyle = AnimationStyle (
500+ curve: defaultAnimationCurve,
501+ duration: defaultAnimationDuration,
502+ );
503+
510504 /// A default of [Curves.linear] , which is used in the tree's expanding and
511505 /// collapsing node animation.
512506 static const Curve defaultAnimationCurve = Curves .linear;
@@ -553,7 +547,8 @@ class TreeView<T> extends StatefulWidget {
553547 );
554548 }
555549
556- /// Returns the default tree row for a given [TreeViewNode] .
550+ /// Default builder for the widget representing a given [TreeViewNode] in the
551+ /// tree.
557552 ///
558553 /// Used by [TreeView.treeNodeBuilder] .
559554 ///
@@ -582,7 +577,7 @@ class TreeView<T> extends StatefulWidget {
582577 dimension: 30.0 ,
583578 child: node.children.isNotEmpty
584579 ? AnimatedRotation (
585- key: Key ('$index - ${ node . content } ' ),
580+ key: Key ('$index ' ),
586581 turns: node.isExpanded ? 0.25 : 0.0 ,
587582 duration: animationDuration,
588583 curve: animationCurve,
@@ -744,11 +739,7 @@ class _TreeViewState<T> extends State<TreeView<T>>
744739 Widget child = widget.treeNodeBuilder (
745740 context,
746741 node,
747- widget.toggleAnimationStyle ??
748- AnimationStyle (
749- curve: TreeView .defaultAnimationCurve,
750- duration: TreeView .defaultAnimationDuration,
751- ),
742+ widget.toggleAnimationStyle ?? TreeView .defaultToggleAnimationStyle,
752743 );
753744
754745 if (widget.addRepaintBoundaries) {
@@ -761,7 +752,6 @@ class _TreeViewState<T> extends State<TreeView<T>>
761752 return widget.treeRowBuilder (_activeNodes[vicinity.row]);
762753 },
763754 addAutomaticKeepAlives: widget.addAutomaticKeepAlives,
764- traversalOrder: widget.traversalOrder,
765755 indentation: widget.indentation.value,
766756 );
767757 }
@@ -971,7 +961,6 @@ class _TreeView extends TwoDimensionalScrollView {
971961 super .clipBehavior,
972962 required TwoDimensionalIndexedWidgetBuilder nodeBuilder,
973963 required TreeVicinityToRowBuilder rowBuilder,
974- this .traversalOrder = TreeViewTraversalOrder .depthFirst,
975964 required this .activeAnimations,
976965 required this .rowDepths,
977966 required this .indentation,
@@ -989,7 +978,6 @@ class _TreeView extends TwoDimensionalScrollView {
989978
990979 final Map <UniqueKey , TreeViewNodesAnimation > activeAnimations;
991980 final Map <int , int > rowDepths;
992- final TreeViewTraversalOrder traversalOrder;
993981 final double indentation;
994982
995983 @override
@@ -1008,7 +996,6 @@ class _TreeView extends TwoDimensionalScrollView {
1008996 clipBehavior: clipBehavior,
1009997 activeAnimations: activeAnimations,
1010998 rowDepths: rowDepths,
1011- traversalOrder: traversalOrder,
1012999 indentation: indentation,
10131000 );
10141001 }
@@ -1030,15 +1017,10 @@ class TreeViewport extends TwoDimensionalViewport {
10301017 super .clipBehavior,
10311018 required this .activeAnimations,
10321019 required this .rowDepths,
1033- this .traversalOrder = TreeViewTraversalOrder .depthFirst,
10341020 required this .indentation,
10351021 }) : assert (verticalAxisDirection == AxisDirection .down &&
10361022 horizontalAxisDirection == AxisDirection .right),
1037- super (
1038- mainAxis: traversalOrder == TreeViewTraversalOrder .depthFirst
1039- ? Axis .vertical
1040- : Axis .horizontal,
1041- );
1023+ super (mainAxis: Axis .vertical);
10421024
10431025 /// The currently active [TreeViewNode] animations.
10441026 ///
@@ -1048,16 +1030,8 @@ class TreeViewport extends TwoDimensionalViewport {
10481030 final Map <UniqueKey , TreeViewNodesAnimation > activeAnimations;
10491031
10501032 /// The depth of each active [TreeNode] .
1051- ///
1052- /// This is used to properly traverse nodes according to
1053- /// [traversalOrder] .
10541033 final Map <int , int > rowDepths;
10551034
1056- /// The order in which child nodes of the tree will be traversed.
1057- ///
1058- /// The default traversal order is [TreeViewTraversalOrder.depthFirst] .
1059- final TreeViewTraversalOrder traversalOrder;
1060-
10611035 /// The number of pixels by which child nodes will be offset in the cross axis
10621036 /// based on their [TreeViewNode.depth] .
10631037 ///
@@ -1070,7 +1044,6 @@ class TreeViewport extends TwoDimensionalViewport {
10701044 return RenderTreeViewport (
10711045 activeAnimations: activeAnimations,
10721046 rowDepths: rowDepths,
1073- traversalOrder: traversalOrder,
10741047 indentation: indentation,
10751048 horizontalOffset: horizontalOffset,
10761049 horizontalAxisDirection: horizontalAxisDirection,
@@ -1091,7 +1064,6 @@ class TreeViewport extends TwoDimensionalViewport {
10911064 renderObject
10921065 ..activeAnimations = activeAnimations
10931066 ..rowDepths = rowDepths
1094- ..traversalOrder = traversalOrder
10951067 ..indentation = indentation
10961068 ..horizontalOffset = horizontalOffset
10971069 ..horizontalAxisDirection = horizontalAxisDirection
0 commit comments