Skip to content

Commit 679e5d1

Browse files
authored
Enable ColumnData and subclasses to be const (#9326)
1 parent 4347294 commit 679e5d1

29 files changed

+162
-172
lines changed

packages/devtools_app/lib/src/screens/app_size/app_size_table.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AppSizeAnalysisTable extends StatelessWidget {
2222
? rootNode.children.first.level
2323
: rootNode.level,
2424
);
25-
final sizeColumn = _SizeColumn();
25+
const sizeColumn = _SizeColumn();
2626
final columns = List<ColumnData<TreemapNode>>.unmodifiable([
2727
treeColumn,
2828
sizeColumn,
@@ -77,7 +77,8 @@ class AppSizeAnalysisTable extends StatelessWidget {
7777
}
7878

7979
class _NameColumn extends TreeColumnData<TreemapNode> {
80-
_NameColumn({required this.currentRootLevel}) : super('Library or Class');
80+
const _NameColumn({required this.currentRootLevel})
81+
: super('Library or Class');
8182

8283
final int currentRootLevel;
8384

@@ -98,7 +99,7 @@ class _NameColumn extends TreeColumnData<TreemapNode> {
9899
}
99100

100101
class _SizeColumn extends ColumnData<TreemapNode> {
101-
_SizeColumn()
102+
const _SizeColumn()
102103
: super('Size', alignment: ColumnAlignment.right, fixedWidthPx: 100.0);
103104

104105
@override
@@ -118,7 +119,7 @@ class _SizeColumn extends ColumnData<TreemapNode> {
118119
}
119120

120121
class _SizePercentageColumn extends ColumnData<TreemapNode> {
121-
_SizePercentageColumn({required this.totalSize})
122+
const _SizePercentageColumn({required this.totalSize})
122123
: super(
123124
'% of Total Size',
124125
alignment: ColumnAlignment.right,
@@ -146,7 +147,7 @@ class _SizePercentageColumn extends ColumnData<TreemapNode> {
146147
class AppSizeDiffTable extends StatelessWidget {
147148
factory AppSizeDiffTable({required TreemapNode rootNode}) {
148149
final treeColumn = _NameColumn(currentRootLevel: rootNode.level);
149-
final diffColumn = _DiffColumn();
150+
const diffColumn = _DiffColumn();
150151
final columns = List<ColumnData<TreemapNode>>.unmodifiable([
151152
treeColumn,
152153
diffColumn,
@@ -188,7 +189,7 @@ class AppSizeDiffTable extends StatelessWidget {
188189
// TODO(peterdjlee): Add an opaque overlay / background to differentiate from
189190
// other columns.
190191
class _DiffColumn extends ColumnData<TreemapNode> {
191-
_DiffColumn()
192+
const _DiffColumn()
192193
: super('Change', alignment: ColumnAlignment.right, fixedWidthPx: 100.0);
193194

194195
// Ensure sort by absolute size.

packages/devtools_app/lib/src/screens/app_size/code_size_attribution.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ class _CallGraphTable extends StatelessWidget {
211211
required this.onNodeSelected,
212212
});
213213

214-
static final _toColumn = ToColumn();
215-
static final _fromColumn = FromColumn();
214+
static const _toColumn = ToColumn();
215+
static const _fromColumn = FromColumn();
216216

217217
final _CallGraphTableType tableType;
218218

@@ -240,14 +240,14 @@ class _CallGraphTable extends StatelessWidget {
240240
}
241241

242242
class FromColumn extends ColumnData<CallGraphNode> {
243-
FromColumn() : super.wide('From');
243+
const FromColumn() : super.wide('From');
244244

245245
@override
246246
String getValue(CallGraphNode dataObject) => dataObject.display;
247247
}
248248

249249
class ToColumn extends ColumnData<CallGraphNode> {
250-
ToColumn() : super.wide('To');
250+
const ToColumn() : super.wide('To');
251251

252252
@override
253253
ColumnAlignment get alignment => ColumnAlignment.right;
@@ -260,7 +260,7 @@ class ToColumn extends ColumnData<CallGraphNode> {
260260
}
261261

262262
class DominatorTree extends StatelessWidget {
263-
DominatorTree({
263+
const DominatorTree({
264264
super.key,
265265
required this.dominatorTreeRoot,
266266
required this.selectedNode,
@@ -272,7 +272,7 @@ class DominatorTree extends StatelessWidget {
272272

273273
final CallGraphNode? selectedNode;
274274

275-
final _packageColumn = _PackageColumn();
275+
static const _packageColumn = _PackageColumn();
276276

277277
@override
278278
Widget build(BuildContext context) {
@@ -283,7 +283,7 @@ class DominatorTree extends StatelessWidget {
283283
dataRoots: [dominatorTreeRoot!],
284284
dataKey: 'dominator-tree',
285285
keyFactory: (node) => PageStorageKey<String>('${node.callGraphNode.id}'),
286-
columns: [_packageColumn],
286+
columns: const [_packageColumn],
287287
treeColumn: _packageColumn,
288288
defaultSortColumn: _packageColumn,
289289
defaultSortDirection: SortDirection.descending,
@@ -304,7 +304,7 @@ class DominatorTree extends StatelessWidget {
304304
}
305305

306306
class _PackageColumn extends TreeColumnData<DominatorTreeNode> {
307-
_PackageColumn() : super('Package');
307+
const _PackageColumn() : super('Package');
308308

309309
@override
310310
String getValue(DominatorTreeNode dataObject) =>

packages/devtools_app/lib/src/screens/deep_link_validation/deep_link_list_view.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ class _DataTable extends StatelessWidget {
207207
...(() {
208208
switch (viewType) {
209209
case TableViewType.domainView:
210-
return [domain, NumberOfAssociatedPathColumn()];
210+
return [domain, const NumberOfAssociatedPathColumn()];
211211
case TableViewType.pathView:
212-
return [path, NumberOfAssociatedDomainColumn()];
212+
return [path, const NumberOfAssociatedDomainColumn()];
213213
case TableViewType.singleUrlView:
214214
return <ColumnData<LinkData>>[domain, path];
215215
}
@@ -218,7 +218,7 @@ class _DataTable extends StatelessWidget {
218218
OSColumn(controller),
219219
if (!controller.displayOptionsNotifier.value.showSplitScreen) ...[
220220
StatusColumn(controller, viewType),
221-
NavigationColumn(),
221+
const NavigationColumn(),
222222
],
223223
],
224224
selectionNotifier: controller.selectedLink,

packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,17 @@ class PathColumn extends ColumnData<LinkData>
672672
}
673673

674674
class NumberOfAssociatedPathColumn extends ColumnData<LinkData> {
675-
NumberOfAssociatedPathColumn() : super.wide('Number of associated path');
675+
const NumberOfAssociatedPathColumn()
676+
: super.wide('Number of associated path');
676677

677678
@override
678679
String getValue(LinkData dataObject) =>
679680
dataObject.associatedPath.length.toString();
680681
}
681682

682683
class NumberOfAssociatedDomainColumn extends ColumnData<LinkData> {
683-
NumberOfAssociatedDomainColumn() : super.wide('Number of associated domain');
684+
const NumberOfAssociatedDomainColumn()
685+
: super.wide('Number of associated domain');
684686

685687
@override
686688
String getValue(LinkData dataObject) =>
@@ -741,9 +743,9 @@ class SchemeColumn extends ColumnData<LinkData>
741743

742744
class OSColumn extends ColumnData<LinkData>
743745
implements ColumnRenderer<LinkData>, ColumnHeaderRenderer<LinkData> {
744-
OSColumn(this.controller) : super.wide('OS');
746+
const OSColumn(this.controller) : super.wide('OS');
745747

746-
DeepLinksController controller;
748+
final DeepLinksController controller;
747749

748750
@override
749751
bool get supportsSorting {
@@ -874,7 +876,7 @@ class StatusColumn extends ColumnData<LinkData>
874876

875877
class NavigationColumn extends ColumnData<LinkData>
876878
implements ColumnRenderer<LinkData> {
877-
NavigationColumn() : super('', fixedWidthPx: 40);
879+
const NavigationColumn() : super('', fixedWidthPx: 40);
878880

879881
@override
880882
bool get supportsSorting => false;

packages/devtools_app/lib/src/screens/logging/_logs_table.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class LogsTable extends StatelessWidget {
2929
final ValueListenable<List<LogData>> searchMatchesNotifier;
3030
final ValueListenable<LogData?> activeSearchMatchNotifier;
3131

32-
static final whenColumn = WhenColumn();
33-
static final messageColumn = MessageColumn();
32+
static const whenColumn = WhenColumn();
33+
static const messageColumn = MessageColumn();
3434
static final columns = [whenColumn, messageColumn];
3535

3636
@override

packages/devtools_app/lib/src/screens/logging/_message_column.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'metadata.dart';
1313

1414
class MessageColumn extends ColumnData<LogData>
1515
implements ColumnRenderer<LogData> {
16-
MessageColumn() : super.wide('Log');
16+
const MessageColumn() : super.wide('Log');
1717

1818
@override
1919
bool get supportsSorting => false;

packages/devtools_app/lib/src/screens/logging/_when_column.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import '../../shared/table/table_data.dart';
66
import 'logging_controller.dart';
77

88
class WhenColumn extends ColumnData<LogData> {
9-
WhenColumn() : super('When', fixedWidthPx: 80);
9+
const WhenColumn() : super('When', fixedWidthPx: 80);
1010

1111
@override
1212
bool get supportsSorting => false;

packages/devtools_app/lib/src/screens/memory/panes/diff/widgets/class_details/paths.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import '../../../../shared/primitives/simple_elements.dart';
1515
import '../../controller/class_data.dart';
1616

1717
class _RetainingPathColumn extends ColumnData<PathData> {
18-
_RetainingPathColumn(String className)
18+
const _RetainingPathColumn(String className)
1919
: super.wide(
2020
'Shortest Retaining Path for Instances of $className',
2121
titleTooltip:
@@ -33,7 +33,7 @@ class _RetainingPathColumn extends ColumnData<PathData> {
3333
}
3434

3535
class _InstanceColumn extends ColumnData<PathData> {
36-
_InstanceColumn(bool isDiff)
36+
const _InstanceColumn(bool isDiff)
3737
: super(
3838
isDiff ? 'Instance\nDelta' : 'Instances',
3939
titleTooltip:

packages/devtools_app/lib/src/screens/memory/panes/diff/widgets/classes_table_diff.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _ClassNameColumn extends ColumnData<DiffClassData>
2525
implements
2626
ColumnRenderer<DiffClassData>,
2727
ColumnHeaderRenderer<DiffClassData> {
28-
_ClassNameColumn(this.diffData)
28+
const _ClassNameColumn(this.diffData)
2929
: super(
3030
'Class',
3131
titleTooltip: 'Class name',

packages/devtools_app/lib/src/screens/memory/panes/diff/widgets/classes_table_single.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class _ClassNameColumn extends ColumnData<SingleClassData>
2222
implements
2323
ColumnRenderer<SingleClassData>,
2424
ColumnHeaderRenderer<SingleClassData> {
25-
_ClassNameColumn(this.data)
25+
const _ClassNameColumn(this.data)
2626
: super(
2727
'Class',
2828
titleTooltip: 'Class name',
@@ -72,7 +72,7 @@ class _ClassNameColumn extends ColumnData<SingleClassData>
7272

7373
class _InstanceColumn extends ColumnData<SingleClassData>
7474
implements ColumnRenderer<SingleClassData> {
75-
_InstanceColumn(this.classData)
75+
const _InstanceColumn(this.classData)
7676
: super(
7777
'Instances',
7878
titleTooltip: nonGcableInstancesColumnTooltip,

0 commit comments

Comments
 (0)