Skip to content

Commit cd5a93a

Browse files
authored
Add scroll controller to debug tree view (#8)
1 parent 1ba5de7 commit cd5a93a

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

lib/src/widgets/debug_tree_view.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class DebugTreeView extends StatelessWidget {
1616
required this.nodeBuilder,
1717
this.listPadding,
1818
this.listGradientColor,
19+
this.scrollController,
1920
}) : nodes = copyTreeNodes(nodes);
2021

2122
/// List of root level tree nodes.
@@ -34,13 +35,17 @@ class DebugTreeView extends StatelessWidget {
3435
/// Color for the gradient background of the list view.
3536
final Color? listGradientColor;
3637

38+
/// Scroll controller for the list view.
39+
final ScrollController? scrollController;
40+
3741
@override
3842
Widget build(BuildContext context) {
3943
final flattenedTreeNode = FlattenTreeNode.getFlattenedTree(
4044
nodes,
4145
treeController,
4246
);
4347
return FlutterFlowGradientScrollView(
48+
scrollController: scrollController,
4449
gradientHeight: 100,
4550
gradientColor: listGradientColor,
4651
child: (controller) => ListView.builder(

lib/src/widgets/flutterflow_gradient_scroll_view.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ class FlutterFlowGradientScrollView extends StatefulWidget {
1414
/// it will use the panel color.
1515
///
1616
/// * [gradientHeight] parameter is the height of the gradient. Default is 50.0.
17+
///
18+
/// * [scrollController] parameter is the scroll controller for the scroll view.
1719
const FlutterFlowGradientScrollView({
1820
super.key,
1921
required this.child,
2022
this.gradientColor,
2123
this.gradientHeight = 50.0,
24+
this.scrollController,
2225
});
2326

2427
/// The child widget that will be scrolled.
@@ -30,6 +33,9 @@ class FlutterFlowGradientScrollView extends StatefulWidget {
3033
/// The height of the gradient. Default is 50.0.
3134
final double gradientHeight;
3235

36+
/// The scroll controller for the scroll view.
37+
final ScrollController? scrollController;
38+
3339
@override
3440
State<FlutterFlowGradientScrollView> createState() =>
3541
_FlutterFlowGradientScrollViewState();
@@ -40,7 +46,14 @@ class _FlutterFlowGradientScrollViewState
4046
var _showStartGradient = false;
4147
var _showEndGradient = false;
4248
double? _maxScrollExtent;
43-
final _scrollController = ScrollController();
49+
50+
late final ScrollController _scrollController;
51+
52+
@override
53+
void initState() {
54+
super.initState();
55+
_scrollController = widget.scrollController ?? ScrollController();
56+
}
4457

4558
@override
4659
Widget build(BuildContext context) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 0.2.2
19+
version: 0.2.3
2020

2121
environment:
2222
sdk: ">=3.4.3 <4.0.0"

0 commit comments

Comments
 (0)