Skip to content

Commit 6b9ba48

Browse files
authored
Add a horizontal scrollbar to DevTools tables (#9482)
1 parent 9701f74 commit 6b9ba48

21 files changed

Lines changed: 206 additions & 223 deletions

packages/devtools_app/lib/src/screens/memory/panes/profile/profile_view.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ class _GCStatsTable extends StatelessWidget {
404404
columns: _columns,
405405
defaultSortColumn: _columns.first,
406406
defaultSortDirection: SortDirection.ascending,
407+
sizeColumnsToFit: false,
407408
),
408409
);
409410
},
@@ -426,6 +427,8 @@ class AllocationProfileTableView extends StatefulWidget {
426427

427428
class AllocationProfileTableViewState
428429
extends State<AllocationProfileTableView> {
430+
static const _scrollbarHeight = 10.0;
431+
429432
@override
430433
void initState() {
431434
super.initState();
@@ -459,7 +462,10 @@ class AllocationProfileTableViewState
459462
// and columns) and one data row. We add a slight padding to
460463
// ensure the underlying scrollable area has enough space to not
461464
// display a scroll bar.
462-
height: defaultRowHeight + defaultHeaderHeight * 2 + 1,
465+
height:
466+
defaultRowHeight +
467+
defaultHeaderHeight * 2 +
468+
_scrollbarHeight,
463469
child: _GCStatsTable(controller: widget.controller),
464470
),
465471
const ThickDivider(),

packages/devtools_app/lib/src/shared/table/_flat_table.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ class FlatTableState<T> extends State<FlatTable<T>> with AutoDisposeMixin {
317317

318318
Widget _buildRow({
319319
required BuildContext context,
320-
required LinkedScrollControllerGroup linkedScrollControllerGroup,
321320
required int index,
322321
required List<double> columnWidths,
323322
required bool isPinned,
@@ -327,7 +326,6 @@ class FlatTableState<T> extends State<FlatTable<T>> with AutoDisposeMixin {
327326
final data = isPinned ? pinnedData : tableController.tableData.value.data;
328327
if (index >= data.length) {
329328
return TableRow<T>.filler(
330-
linkedScrollControllerGroup: linkedScrollControllerGroup,
331329
columns: tableController.columns,
332330
columnGroups: tableController.columnGroups,
333331
columnWidths: columnWidths,
@@ -344,7 +342,6 @@ class FlatTableState<T> extends State<FlatTable<T>> with AutoDisposeMixin {
344342
builder: (context, selected, _) {
345343
return TableRow<T>(
346344
key: widget.keyFactory(node),
347-
linkedScrollControllerGroup: linkedScrollControllerGroup,
348345
node: node,
349346
onPressed: (T? selection) {
350347
widget.selectionNotifier.value = selection;

packages/devtools_app/lib/src/shared/table/_table_column.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,12 @@ class _ColumnGroupHeaderRow extends StatelessWidget {
129129
const _ColumnGroupHeaderRow({
130130
required this.groups,
131131
required this.columnWidths,
132-
required this.scrollController,
133132
});
134133

135134
final List<ColumnGroup> groups;
136135

137136
final List<double> columnWidths;
138137

139-
final ScrollController scrollController;
140-
141138
@override
142139
Widget build(BuildContext context) {
143140
return Container(
@@ -147,7 +144,6 @@ class _ColumnGroupHeaderRow extends StatelessWidget {
147144
),
148145
child: ListView.builder(
149146
scrollDirection: Axis.horizontal,
150-
controller: scrollController,
151147
itemCount: groups.length + groups.numSpacers,
152148
itemBuilder: (context, int i) {
153149
if (i % 2 == 1) {

packages/devtools_app/lib/src/shared/table/_table_row.dart

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class TableRow<T> extends StatefulWidget {
1818
/// [node].
1919
const TableRow({
2020
super.key,
21-
required this.linkedScrollControllerGroup,
2221
required this.node,
2322
required this.columns,
2423
required this.columnWidths,
@@ -44,7 +43,6 @@ class TableRow<T> extends StatefulWidget {
4443
/// Constructs a [TableRow] that is empty.
4544
const TableRow.filler({
4645
super.key,
47-
required this.linkedScrollControllerGroup,
4846
required this.columns,
4947
required this.columnWidths,
5048
this.columnGroups,
@@ -71,7 +69,6 @@ class TableRow<T> extends StatefulWidget {
7169
/// of any [node].
7270
const TableRow.tableColumnHeader({
7371
super.key,
74-
required this.linkedScrollControllerGroup,
7572
required this.columns,
7673
required this.columnWidths,
7774
required this.columnGroups,
@@ -98,7 +95,6 @@ class TableRow<T> extends StatefulWidget {
9895
/// [node].
9996
const TableRow.tableColumnGroupHeader({
10097
super.key,
101-
required this.linkedScrollControllerGroup,
10298
required this.columnGroups,
10399
required this.columnWidths,
104100
required this.sortColumn,
@@ -121,8 +117,6 @@ class TableRow<T> extends StatefulWidget {
121117
enableHoverHandling = false,
122118
_rowType = _TableRowType.columnGroupHeader;
123119

124-
final LinkedScrollControllerGroup linkedScrollControllerGroup;
125-
126120
final T? node;
127121

128122
final List<ColumnData<T>> columns;
@@ -200,8 +194,6 @@ class _TableRowState<T> extends State<TableRow<T>>
200194
SearchableMixin {
201195
Key? contentKey;
202196

203-
late ScrollController scrollController;
204-
205197
bool isSearchMatch = false;
206198

207199
bool isActiveSearchMatch = false;
@@ -216,7 +208,6 @@ class _TableRowState<T> extends State<TableRow<T>>
216208
void initState() {
217209
super.initState();
218210
contentKey = ValueKey(this);
219-
scrollController = widget.linkedScrollControllerGroup.addAndGet();
220211
_initSearchListeners();
221212

222213
_rowDisplayParts = _rowDisplayPartsHelper();
@@ -242,11 +233,6 @@ class _TableRowState<T> extends State<TableRow<T>>
242233
void didUpdateWidget(TableRow<T> oldWidget) {
243234
super.didUpdateWidget(oldWidget);
244235
setExpanded(widget.isExpanded);
245-
if (oldWidget.linkedScrollControllerGroup !=
246-
widget.linkedScrollControllerGroup) {
247-
scrollController.dispose();
248-
scrollController = widget.linkedScrollControllerGroup.addAndGet();
249-
}
250236

251237
_rowDisplayParts = _rowDisplayPartsHelper();
252238

@@ -256,12 +242,6 @@ class _TableRowState<T> extends State<TableRow<T>>
256242
_initSearchListeners();
257243
}
258244

259-
@override
260-
void dispose() {
261-
scrollController.dispose();
262-
super.dispose();
263-
}
264-
265245
@override
266246
Widget build(BuildContext context) {
267247
final node = widget.node;
@@ -530,18 +510,13 @@ class _TableRowState<T> extends State<TableRow<T>>
530510
return _ColumnGroupHeaderRow(
531511
groups: groups,
532512
columnWidths: widget.columnWidths,
533-
scrollController: scrollController,
534513
);
535514
}
536515

537516
Widget rowContent = Padding(
538517
padding: const EdgeInsets.symmetric(horizontal: defaultSpacing),
539-
child: ExtentDelegateListView(
540-
scrollDirection: Axis.horizontal,
541-
physics: const ClampingScrollPhysics(),
542-
controller: scrollController,
543-
extentDelegate: rowExtentDelegate,
544-
childrenDelegate: SliverChildBuilderDelegate((context, int i) {
518+
child: Row(
519+
children: List.generate(_rowDisplayParts.length, (int i) {
545520
final columnIndexMap = _columnIndexMapHelper(_rowDisplayParts);
546521
final displayTypeForIndex = _rowDisplayParts[i];
547522
switch (displayTypeForIndex) {
@@ -559,7 +534,7 @@ class _TableRowState<T> extends State<TableRow<T>>
559534
case _TableRowPartDisplayType.columnGroupSpacer:
560535
return const _ColumnGroupSpacer();
561536
}
562-
}, childCount: _rowDisplayParts.length),
537+
}),
563538
),
564539
);
565540

packages/devtools_app/lib/src/shared/table/_tree_table.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ class TreeTableState<T extends TreeNode<T>> extends State<TreeTable<T>>
282282

283283
Widget _buildRow({
284284
required BuildContext context,
285-
required LinkedScrollControllerGroup linkedScrollControllerGroup,
286285
required int index,
287286
required List<double> columnWidths,
288287
required bool isPinned,
@@ -293,7 +292,6 @@ class TreeTableState<T extends TreeNode<T>> extends State<TreeTable<T>>
293292
node.index = index;
294293
return TableRow<T>(
295294
key: widget.keyFactory(node),
296-
linkedScrollControllerGroup: linkedScrollControllerGroup,
297295
node: node,
298296
onPressed: (item) => _onItemPressed(item, index),
299297
backgroundColor: alternatingColorForIndex(

0 commit comments

Comments
 (0)