New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SliverTreeList #147171
base: master
Are you sure you want to change the base?
SliverTreeList #147171
Conversation
For tomorrow:
|
/// | ||
/// ** See code in examples/api/lib/widgets/sliver/sliver_tree.1.dart ** | ||
/// {@end-tool} | ||
class SliverTreeList<T> extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not love this name, but SliverTree and SliverAnimatedTree are taken. Open to other ideas. I think this works because the tree itself is flattened to a list of active nodes.
And it subclasses SliverVariedExtentList. So.. it's list-y.
/// the [SliverTreeList.defaultAnimationCurve], which is [Curves.linear]. | ||
/// | ||
/// To disable the tree animation, use [AnimationStyle.noAnimation]. | ||
final AnimationStyle? animationStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
animationStyle
could be named toggleAnimationStyle
, which makes it easier to understand what type of animation this property customizes. In this case it used for toggle animation based on the docs. (Noticed this when reviewing examples)
E.g. expansionAnimationStyle is used to customize ExpansionTile
expand/collapse animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the examples!
Spotted minor typos in the non-examples files.
// unpack. | ||
return true; | ||
} | ||
// If we are not animating, respect node.isExpanded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If we are not animating, respect node.isExpanded; | |
// If we are not animating, respect node.isExpanded. |
_currentLayoutDimensions = SliverLayoutDimensions( | ||
scrollOffset: constraints.scrollOffset, | ||
precedingScrollExtent: constraints.precedingScrollExtent, | ||
viewportMainAxisExtent: constraints.viewportMainAxisExtent, | ||
crossAxisExtent: constraints.crossAxisExtent | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation + missing comma at the end
/// | ||
/// 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 an [SliverTreeList] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an -> a (same on lines 158, 178, 231, 266 and 293)
SliverTreeList<String>( | ||
tree: _tree, | ||
controller: controller, | ||
treeNodeBuilder: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('SliverTree demo'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: const Text('SliverTree demo'), | |
title: const Text('SliverTree Demo'), |
? Icons.file_open_outlined | ||
: Icons.folder_outlined, | ||
), | ||
const SizedBox(height: 25.0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SizedBox(height: 25.0), | |
const SizedBox(height: 16.0), |
Reduced the padding between selection icon and label.
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('SliverTree example', (WidgetTester tester) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testWidgets('SliverTree example', (WidgetTester tester) async { | |
testWidgets('Can toggle nodes in SliverTree', (WidgetTester tester) async { |
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('SliverTree example', (WidgetTester tester) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testWidgets('SliverTree example', (WidgetTester tester) async { | |
testWidgets('Can toggle nodes in SliverTree', (WidgetTester tester) async { |
); | ||
expect(find.text('lib'), findsOneWidget); | ||
expect(find.text('src'), findsNothing); | ||
// Toggle tree node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Toggle tree node | |
// Toggle tree node. |
); | ||
expect(find.text('Second'), findsOneWidget); | ||
expect(find.text('alpha'), findsNothing); | ||
// Toggle tree node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Toggle tree node | |
// Toggle tree node. |
FYI for Reviewers: Much of the API surface matches that of the 2D TreeView in flutter/packages#6592. If it changes here, it should change there, and vice versa.
📜 Design Document
This adds classes and associated callbacks and controllers for SliverTree. Core components:
Fixes #114299
sliver_0.mov
sliver_1.mov
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.