Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 6a54059

Browse files
authored
Make MultiChildRenderObjectWidget const (#119195)
1 parent 9b3b9cf commit 6a54059

37 files changed

+415
-417
lines changed

dev/benchmarks/platform_views_layout/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class PlatformViewLayout extends StatelessWidget {
5555
child: Material(
5656
elevation: (index % 5 + 1).toDouble(),
5757
color: Colors.white,
58-
child: Stack(
59-
children: const <Widget> [
58+
child: const Stack(
59+
children: <Widget> [
6060
DummyPlatformView(),
6161
RotationContainer(),
6262
],

dev/benchmarks/platform_views_layout_hybrid_composition/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class PlatformViewLayout extends StatelessWidget {
5959
child: Material(
6060
elevation: (index % 5 + 1).toDouble(),
6161
color: Colors.white,
62-
child: Stack(
63-
children: const <Widget> [
62+
child: const Stack(
63+
children: <Widget> [
6464
DummyPlatformView(),
6565
RotationContainer(),
6666
],

dev/integration_tests/android_semantics_testing/lib/src/tests/popup_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class _PopupControlsPageState extends State<PopupControlsPage> {
7777
return AlertDialog(
7878
key: const ValueKey<String>(alertKeyValue),
7979
title: const Text('Title text', key: ValueKey<String>('$alertKeyValue.Title')),
80-
content: SingleChildScrollView(
80+
content: const SingleChildScrollView(
8181
child: ListBody(
82-
children: const <Widget>[
82+
children: <Widget>[
8383
Text('Body text line 1.', key: ValueKey<String>('$alertKeyValue.Body1')),
8484
Text('Body text line 2.', key: ValueKey<String>('$alertKeyValue.Body2')),
8585
],

packages/flutter/lib/src/cupertino/dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ class CupertinoDialogAction extends StatelessWidget {
17631763
//
17641764
// See [_RenderCupertinoDialogActions] for specific layout policy details.
17651765
class _CupertinoDialogActionsRenderWidget extends MultiChildRenderObjectWidget {
1766-
_CupertinoDialogActionsRenderWidget({
1766+
const _CupertinoDialogActionsRenderWidget({
17671767
required List<Widget> actionButtons,
17681768
double dividerThickness = 0.0,
17691769
bool hasCancelButton = false,

packages/flutter/lib/src/cupertino/segmented_control.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC
405405
}
406406

407407
class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
408-
_SegmentedControlRenderWidget({
408+
const _SegmentedControlRenderWidget({
409409
super.key,
410410
super.children,
411411
required this.selectedIndex,

packages/flutter/lib/src/cupertino/sliding_segmented_control.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T
711711
}
712712

713713
class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
714-
_SegmentedControlRenderWidget({
714+
const _SegmentedControlRenderWidget({
715715
super.key,
716716
super.children,
717717
required this.highlightedIndex,

packages/flutter/lib/src/material/button_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class ButtonBar extends StatelessWidget {
233233
class _ButtonBarRow extends Flex {
234234
/// Creates a button bar that attempts to display in a row, but displays in
235235
/// a column if there is insufficient horizontal space.
236-
_ButtonBarRow({
236+
const _ButtonBarRow({
237237
required super.children,
238238
super.mainAxisSize,
239239
super.mainAxisAlignment,

packages/flutter/lib/src/material/dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ class Dialog extends StatelessWidget {
302302
/// builder: (BuildContext context) {
303303
/// return AlertDialog(
304304
/// title: const Text('AlertDialog Title'),
305-
/// content: SingleChildScrollView(
305+
/// content: const SingleChildScrollView(
306306
/// child: ListBody(
307-
/// children: const <Widget>[
307+
/// children: <Widget>[
308308
/// Text('This is a demo alert dialog.'),
309309
/// Text('Would you like to approve of this message?'),
310310
/// ],

packages/flutter/lib/src/material/dropdown_menu.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class _ArrowDownIntent extends Intent {
605605
}
606606

607607
class _DropdownMenuBody extends MultiChildRenderObjectWidget {
608-
_DropdownMenuBody({
608+
const _DropdownMenuBody({
609609
super.key,
610610
super.children,
611611
this.width,

packages/flutter/lib/src/material/mergeable_material.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class _MergeableMaterialSliceKey extends GlobalKey {
655655
}
656656

657657
class _MergeableMaterialListBody extends ListBody {
658-
_MergeableMaterialListBody({
658+
const _MergeableMaterialListBody({
659659
required super.children,
660660
super.mainAxis,
661661
required this.items,

packages/flutter/lib/src/material/segmented_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class SegmentedButton<T> extends StatelessWidget {
372372
}
373373
}
374374
class _SegmentedButtonRenderWidget<T> extends MultiChildRenderObjectWidget {
375-
_SegmentedButtonRenderWidget({
375+
const _SegmentedButtonRenderWidget({
376376
super.key,
377377
required this.segments,
378378
required this.enabledBorder,

packages/flutter/lib/src/material/tabs.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class _TabLabelBarRenderer extends RenderFlex {
275275
// upon layout. The tab widths are only used at paint time (see _IndicatorPainter)
276276
// or in response to input.
277277
class _TabLabelBar extends Flex {
278-
_TabLabelBar({
278+
const _TabLabelBar({
279279
super.children,
280280
required this.onPerformLayout,
281281
}) : super(

packages/flutter/lib/src/material/text_selection_toolbar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class _TextSelectionToolbarTrailingEdgeAlignRenderBox extends RenderProxyBox {
373373
// Renders the menu items in the correct positions in the menu and its overflow
374374
// submenu based on calculating which item would first overflow.
375375
class _TextSelectionToolbarItemsLayout extends MultiChildRenderObjectWidget {
376-
_TextSelectionToolbarItemsLayout({
376+
const _TextSelectionToolbarItemsLayout({
377377
required this.isAbove,
378378
required this.overflowOpen,
379379
required super.children,

packages/flutter/lib/src/widgets/basic.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget {
23042304
/// Creates a custom multi-child layout.
23052305
///
23062306
/// The [delegate] argument must not be null.
2307-
CustomMultiChildLayout({
2307+
const CustomMultiChildLayout({
23082308
super.key,
23092309
required this.delegate,
23102310
super.children,
@@ -3666,7 +3666,7 @@ class ListBody extends MultiChildRenderObjectWidget {
36663666
/// given axis.
36673667
///
36683668
/// By default, the [mainAxis] is [Axis.vertical].
3669-
ListBody({
3669+
const ListBody({
36703670
super.key,
36713671
this.mainAxis = Axis.vertical,
36723672
this.reverse = false,
@@ -3825,7 +3825,7 @@ class Stack extends MultiChildRenderObjectWidget {
38253825
///
38263826
/// By default, the non-positioned children of the stack are aligned by their
38273827
/// top left corners.
3828-
Stack({
3828+
const Stack({
38293829
super.key,
38303830
this.alignment = AlignmentDirectional.topStart,
38313831
this.textDirection,
@@ -3941,7 +3941,7 @@ class IndexedStack extends Stack {
39413941
/// Creates a [Stack] widget that paints a single child.
39423942
///
39433943
/// The [index] argument must not be null.
3944-
IndexedStack({
3944+
const IndexedStack({
39453945
super.key,
39463946
super.alignment,
39473947
super.textDirection,
@@ -4445,7 +4445,7 @@ class Flex extends MultiChildRenderObjectWidget {
44454445
/// to be necessary to decide which direction to lay the children in or to
44464446
/// disambiguate `start` or `end` values for the main or cross axis
44474447
/// directions, the [textDirection] must not be null.
4448-
Flex({
4448+
const Flex({
44494449
super.key,
44504450
required this.direction,
44514451
this.mainAxisAlignment = MainAxisAlignment.start,
@@ -4812,7 +4812,7 @@ class Row extends Flex {
48124812
/// unless the row has no children or only one child) or to disambiguate
48134813
/// `start` or `end` values for the [mainAxisAlignment], the [textDirection]
48144814
/// must not be null.
4815-
Row({
4815+
const Row({
48164816
super.key,
48174817
super.mainAxisAlignment,
48184818
super.mainAxisSize,
@@ -5005,7 +5005,7 @@ class Column extends Flex {
50055005
/// any. If there is no ambient directionality, and a text direction is going
50065006
/// to be necessary to disambiguate `start` or `end` values for the
50075007
/// [crossAxisAlignment], the [textDirection] must not be null.
5008-
Column({
5008+
const Column({
50095009
super.key,
50105010
super.mainAxisAlignment,
50115011
super.mainAxisSize,
@@ -5212,7 +5212,7 @@ class Wrap extends MultiChildRenderObjectWidget {
52125212
/// to be necessary to decide which direction to lay the children in or to
52135213
/// disambiguate `start` or `end` values for the main or cross axis
52145214
/// directions, the [textDirection] must not be null.
5215-
Wrap({
5215+
const Wrap({
52165216
super.key,
52175217
this.direction = Axis.horizontal,
52185218
this.alignment = WrapAlignment.start,
@@ -5474,7 +5474,7 @@ class Flow extends MultiChildRenderObjectWidget {
54745474
/// a repaint boundary.
54755475
///
54765476
/// The [delegate] argument must not be null.
5477-
Flow.unwrapped({
5477+
const Flow.unwrapped({
54785478
super.key,
54795479
required this.delegate,
54805480
super.children,

packages/flutter/lib/src/widgets/framework.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,9 +1855,7 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
18551855
///
18561856
/// The [children] argument must not be null and must not contain any null
18571857
/// objects.
1858-
// TODO(goderbauer): Make this const and fix fallout, https://github.com/flutter/flutter/issues/108248
1859-
// ignore: prefer_const_constructors_in_immutables
1860-
MultiChildRenderObjectWidget({ super.key, this.children = const <Widget>[] });
1858+
const MultiChildRenderObjectWidget({ super.key, this.children = const <Widget>[] });
18611859

18621860
/// The widgets below this widget in the tree.
18631861
///

packages/flutter/lib/src/widgets/overflow_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class OverflowBar extends MultiChildRenderObjectWidget {
5959
/// [overflowDirection], and [clipBehavior] parameters must not be
6060
/// null. The [children] argument must not be null and must not contain
6161
/// any null objects.
62-
OverflowBar({
62+
const OverflowBar({
6363
super.key,
6464
this.spacing = 0.0,
6565
this.alignment,

packages/flutter/lib/src/widgets/overlay.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class OverlayState extends State<Overlay> with TickerProviderStateMixin {
637637
///
638638
/// The first [skipCount] children are considered "offstage".
639639
class _Theatre extends MultiChildRenderObjectWidget {
640-
_Theatre({
640+
const _Theatre({
641641
this.skipCount = 0,
642642
this.clipBehavior = Clip.hardEdge,
643643
super.children,

packages/flutter/lib/src/widgets/viewport.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class ShrinkWrappingViewport extends MultiChildRenderObjectWidget {
324324
/// rebuild this widget when the [offset] changes.
325325
///
326326
/// The [offset] argument must not be null.
327-
ShrinkWrappingViewport({
327+
const ShrinkWrappingViewport({
328328
super.key,
329329
this.axisDirection = AxisDirection.down,
330330
this.crossAxisDirection,

packages/flutter/test/cupertino/scaffold_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void main() {
227227
),
228228
child: page1Center,
229229
)
230-
: Stack();
230+
: const Stack();
231231
},
232232
),
233233
),
@@ -270,7 +270,7 @@ void main() {
270270
],
271271
),
272272
)
273-
: Stack();
273+
: const Stack();
274274
},
275275
),
276276
),

packages/flutter/test/material/button_bar_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ void main() {
341341

342342
testWidgets('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async {
343343
await tester.pumpWidget(
344-
SingleChildScrollView(
344+
const SingleChildScrollView(
345345
child: ListBody(
346-
children: const <Widget>[
346+
children: <Widget>[
347347
Directionality(
348348
textDirection: TextDirection.ltr,
349349
child: ButtonBar(
@@ -364,9 +364,9 @@ void main() {
364364

365365
testWidgets('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async {
366366
await tester.pumpWidget(
367-
SingleChildScrollView(
367+
const SingleChildScrollView(
368368
child: ListBody(
369-
children: const <Widget>[
369+
children: <Widget>[
370370
Directionality(
371371
textDirection: TextDirection.ltr,
372372
child: ButtonBar(

packages/flutter/test/material/icons_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ void main() {
6363
testWidgets('A sample of icons look as expected', (WidgetTester tester) async {
6464
await _loadIconFont();
6565

66-
await tester.pumpWidget(MaterialApp(
66+
await tester.pumpWidget(const MaterialApp(
6767
home: IconTheme(
68-
data: const IconThemeData(size: 200),
68+
data: IconThemeData(size: 200),
6969
child: Wrap(
70-
children: const <Icon>[
70+
children: <Icon>[
7171
Icon(Icons.ten_k),
7272
Icon(Icons.ac_unit),
7373
Icon(Icons.local_taxi),
@@ -87,11 +87,11 @@ void main() {
8787
testWidgets('Another sample of icons look as expected', (WidgetTester tester) async {
8888
await _loadIconFont();
8989

90-
await tester.pumpWidget(MaterialApp(
90+
await tester.pumpWidget(const MaterialApp(
9191
home: IconTheme(
92-
data: const IconThemeData(size: 200),
92+
data: IconThemeData(size: 200),
9393
child: Wrap(
94-
children: const <Icon>[
94+
children: <Icon>[
9595
Icon(Icons.water_drop),
9696
Icon(Icons.water_drop_outlined),
9797
Icon(Icons.water_drop_rounded),
@@ -107,11 +107,11 @@ void main() {
107107
testWidgets('Another sample of icons look as expected', (WidgetTester tester) async {
108108
await _loadIconFont();
109109

110-
await tester.pumpWidget(MaterialApp(
110+
await tester.pumpWidget(const MaterialApp(
111111
home: IconTheme(
112-
data: const IconThemeData(size: 200),
112+
data: IconThemeData(size: 200),
113113
child: Wrap(
114-
children: const <Icon>[
114+
children: <Icon>[
115115
Icon(Icons.electric_bolt),
116116
Icon(Icons.electric_bolt_outlined),
117117
Icon(Icons.electric_bolt_rounded),
@@ -128,11 +128,11 @@ void main() {
128128
testWidgets('Another sample of icons look as expected', (WidgetTester tester) async {
129129
await _loadIconFont();
130130

131-
await tester.pumpWidget(MaterialApp(
131+
await tester.pumpWidget(const MaterialApp(
132132
home: IconTheme(
133-
data: const IconThemeData(size: 200),
133+
data: IconThemeData(size: 200),
134134
child: Wrap(
135-
children: const <Icon>[
135+
children: <Icon>[
136136
Icon(Icons.repeat_on),
137137
Icon(Icons.repeat_on_outlined),
138138
Icon(Icons.repeat_on_rounded),

packages/flutter/test/material/input_decorator_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5903,14 +5903,14 @@ void main() {
59035903
};
59045904
try {
59055905
await tester.pumpWidget(
5906-
MaterialApp(
5906+
const MaterialApp(
59075907
home: Center(
59085908
child: Directionality(
59095909
textDirection: TextDirection.ltr,
59105910
child: InputDecorator(
5911-
decoration: const InputDecoration(),
5911+
decoration: InputDecoration(),
59125912
child: Stack(
5913-
children: const <Widget>[
5913+
children: <Widget>[
59145914
SizedBox(height: 0),
59155915
Positioned(
59165916
bottom: 5,

0 commit comments

Comments
 (0)