replace simple empty Container with w & h with SizedBox (#54394)

* replace simple Container(w & h) with SizedBox

* address review comments

* address review comments
This commit is contained in:
Alexandre Ardhuin 2020-04-10 22:32:40 +02:00 committed by GitHub
parent b0610be3b4
commit 7ceed97302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 196 additions and 195 deletions

View file

@ -834,7 +834,7 @@ class _CupertinoAlertContentSection extends StatelessWidget {
if (titleContentGroup.isEmpty) {
return SingleChildScrollView(
controller: scrollController,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),

View file

@ -1036,7 +1036,7 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
),
),
);
final Container spacer = Container(
const SizedBox spacer = SizedBox(
width: _kPadding,
height: _kPadding,
);

View file

@ -867,7 +867,7 @@ class _CupertinoAlertContentSection extends StatelessWidget {
if (title == null && content == null) {
return SingleChildScrollView(
controller: scrollController,
child: Container(width: 0.0, height: 0.0),
child: const SizedBox(width: 0.0, height: 0.0),
);
}

View file

@ -175,7 +175,7 @@ class DataCell {
}) : assert(child != null);
/// A cell that has no content and has zero width and height.
static final DataCell empty = DataCell(Container(width: 0.0, height: 0.0));
static const DataCell empty = DataCell(SizedBox(width: 0.0, height: 0.0));
/// The data for the row.
///

View file

@ -100,7 +100,7 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
// If there is no option available, build an empty widget.
if (items.isEmpty) {
return Container(width: 0.0, height: 0.0);
return const SizedBox(width: 0.0, height: 0.0);
}

View file

@ -236,7 +236,7 @@ void main() {
});
testWidgets('Contents have automatic sliver padding between translucent bars', (WidgetTester tester) async {
final Container content = Container(height: 600.0, width: 600.0);
const SizedBox content = SizedBox(height: 600.0, width: 600.0);
await tester.pumpWidget(
CupertinoApp(
@ -264,7 +264,7 @@ void main() {
middle: Text('Title'),
),
child: ListView(
children: <Widget>[
children: const <Widget>[
content,
],
),

View file

@ -3623,7 +3623,7 @@ void main() {
focusNode: focusNode,
expands: true,
maxLines: null,
prefix: Container(
prefix: const SizedBox(
height: 100,
width: 10,
),
@ -3676,7 +3676,7 @@ void main() {
focusNode: focusNode,
expands: true,
maxLines: null,
prefix: Container(
prefix: const SizedBox(
height: 100,
width: 10,
),
@ -3730,7 +3730,7 @@ void main() {
focusNode: focusNode,
expands: true,
maxLines: null,
prefix: Container(
prefix: const SizedBox(
height: 100,
width: 10,
),
@ -3784,7 +3784,7 @@ void main() {
focusNode: focusNode,
expands: true,
maxLines: null,
prefix: Container(
prefix: const SizedBox(
height: 100,
width: 10,
),

View file

@ -1084,8 +1084,8 @@ void main() {
await tester.pumpAndSettle();
final RenderBox container = tester.renderObject(find.descendant(
of: find.byType(FadeTransition),
matching: find.byType(Container),
));
matching: find.byType(SizedBox),
).first);
expect(container.size, Size.zero);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
@ -2252,7 +2252,7 @@ void main() {
await tester.pumpWidget(containedTextFieldBuilder(
counter: Container(height: counterHeight),
labelText: 'I am labelText',
prefix: Container(
prefix: const SizedBox(
width: 10,
height: 60,
),

View file

@ -61,7 +61,7 @@ void main() {
padding: const EdgeInsets.all(5.0),
verticalOffset: 20.0,
preferBelow: false,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -118,7 +118,7 @@ void main() {
padding: const EdgeInsets.all(5.0),
verticalOffset: 20.0,
preferBelow: false,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -172,7 +172,7 @@ void main() {
padding: const EdgeInsets.all(0.0),
verticalOffset: 100.0,
preferBelow: false,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -228,7 +228,7 @@ void main() {
padding: const EdgeInsets.all(0.0),
verticalOffset: 100.0,
preferBelow: false,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -295,7 +295,7 @@ void main() {
padding: const EdgeInsets.all(0.0),
verticalOffset: 100.0,
preferBelow: true,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -350,7 +350,7 @@ void main() {
padding: const EdgeInsets.all(0.0),
verticalOffset: 10.0,
preferBelow: true,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -407,7 +407,7 @@ void main() {
padding: const EdgeInsets.all(0.0),
verticalOffset: 10.0,
preferBelow: true,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -458,7 +458,7 @@ void main() {
message: tooltipText,
padding: const EdgeInsets.all(0.0),
margin: const EdgeInsets.all(_customMarginValue),
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -654,7 +654,7 @@ void main() {
return Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -696,7 +696,7 @@ void main() {
key: key,
decoration: customDecoration,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -780,12 +780,12 @@ void main() {
await gesture.moveTo(Offset.zero);
await tester.pumpWidget(
MaterialApp(
const MaterialApp(
home: Center(
child: Tooltip(
message: tooltipText,
waitDuration: waitDuration,
child: Container(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -838,7 +838,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(width: 10.0, height: 10.0),
child: const SizedBox(width: 10.0, height: 10.0),
),
),
],

View file

@ -119,7 +119,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -177,7 +177,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -237,7 +237,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -306,7 +306,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -377,7 +377,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -434,7 +434,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -486,7 +486,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -542,7 +542,7 @@ void main() {
child: Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -662,7 +662,7 @@ void main() {
return Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -704,7 +704,7 @@ void main() {
return Tooltip(
key: key,
message: tooltipText,
child: Container(
child: const SizedBox(
width: 0.0,
height: 0.0,
),
@ -837,10 +837,10 @@ void main() {
waitDuration: customWaitDuration,
),
),
child: Center(
child: const Center(
child: Tooltip(
message: tooltipText,
child: Container(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -878,13 +878,13 @@ void main() {
await gesture.moveTo(Offset.zero);
await tester.pumpWidget(
MaterialApp(
const MaterialApp(
home: TooltipTheme(
data: const TooltipThemeData(waitDuration: customWaitDuration),
data: TooltipThemeData(waitDuration: customWaitDuration),
child: Center(
child: Tooltip(
message: tooltipText,
child: Container(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -922,10 +922,10 @@ void main() {
showDuration: customShowDuration,
),
),
child: Center(
child: const Center(
child: Tooltip(
message: tooltipText,
child: Container(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -952,13 +952,13 @@ void main() {
testWidgets('Tooltip showDuration - TooltipTheme', (WidgetTester tester) async {
const Duration customShowDuration = Duration(milliseconds: 3000);
await tester.pumpWidget(
MaterialApp(
const MaterialApp(
home: TooltipTheme(
data: const TooltipThemeData(showDuration: customShowDuration),
data: TooltipThemeData(showDuration: customShowDuration),
child: Center(
child: Tooltip(
message: tooltipText,
child: Container(
child: SizedBox(
width: 100.0,
height: 100.0,
),

View file

@ -44,51 +44,51 @@ void main() {
});
testWidgets('Align control test (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(Directionality(
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr,
child: Align(
child: Container(width: 100.0, height: 80.0),
child: SizedBox(width: 100.0, height: 80.0),
alignment: AlignmentDirectional.topStart,
),
));
expect(tester.getTopLeft(find.byType(Container)).dx, 0.0);
expect(tester.getBottomRight(find.byType(Container)).dx, 100.0);
expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0);
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
await tester.pumpWidget(Directionality(
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr,
child: Align(
child: Container(width: 100.0, height: 80.0),
child: SizedBox(width: 100.0, height: 80.0),
alignment: Alignment.topLeft,
),
));
expect(tester.getTopLeft(find.byType(Container)).dx, 0.0);
expect(tester.getBottomRight(find.byType(Container)).dx, 100.0);
expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0);
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
});
testWidgets('Align control test (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(Directionality(
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.rtl,
child: Align(
child: Container(width: 100.0, height: 80.0),
child: SizedBox(width: 100.0, height: 80.0),
alignment: AlignmentDirectional.topStart,
),
));
expect(tester.getTopLeft(find.byType(Container)).dx, 700.0);
expect(tester.getBottomRight(find.byType(Container)).dx, 800.0);
expect(tester.getTopLeft(find.byType(SizedBox)).dx, 700.0);
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 800.0);
await tester.pumpWidget(Directionality(
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr,
child: Align(
child: Container(width: 100.0, height: 80.0),
child: SizedBox(width: 100.0, height: 80.0),
alignment: Alignment.topLeft,
),
));
expect(tester.getTopLeft(find.byType(Container)).dx, 0.0);
expect(tester.getBottomRight(find.byType(Container)).dx, 100.0);
expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0);
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
});
testWidgets('Shrink wraps in finite space', (WidgetTester tester) async {
@ -97,7 +97,7 @@ void main() {
SingleChildScrollView(
child: Align(
key: alignKey,
child: Container(
child: const SizedBox(
width: 10.0,
height: 10.0,
),

View file

@ -112,7 +112,7 @@ Future<void> main() async {
child: Container(
key: key,
decoration: BoxDecoration(border: Border.all(width: 10.0)),
child: Container(
child: const SizedBox(
width: 25.0,
height: 25.0,
),

View file

@ -338,9 +338,9 @@ void main() {
await tester.pumpWidget(Center(
child: Column(
key: flexKey,
children: <Widget>[
Container(width: 100.0, height: 100.0),
Container(width: 100.0, height: 150.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
SizedBox(width: 100.0, height: 150.0),
],
),
));
@ -353,9 +353,9 @@ void main() {
child: Column(
key: flexKey,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(width: 100.0, height: 100.0),
Container(width: 100.0, height: 150.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
SizedBox(width: 100.0, height: 150.0),
],
),
));
@ -729,9 +729,9 @@ void main() {
child: Column(
key: flexKey,
verticalDirection: VerticalDirection.up,
children: <Widget>[
Container(width: 100.0, height: 100.0),
Container(width: 100.0, height: 150.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
SizedBox(width: 100.0, height: 150.0),
],
),
));
@ -745,9 +745,9 @@ void main() {
key: flexKey,
mainAxisSize: MainAxisSize.min,
verticalDirection: VerticalDirection.up,
children: <Widget>[
Container(width: 100.0, height: 100.0),
Container(width: 100.0, height: 150.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
SizedBox(width: 100.0, height: 150.0),
],
),
));

View file

@ -20,7 +20,7 @@ void main() {
top: 456.0,
child: CompositedTransformTarget(
link: link,
child: Container(height: 10.0, width: 10.0),
child: const SizedBox(height: 10.0, width: 10.0),
),
),
Positioned(

View file

@ -49,8 +49,8 @@ Widget buildFrame(MultiChildLayoutDelegate delegate) {
return Center(
child: CustomMultiChildLayout(
children: <Widget>[
LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)),
LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)),
LayoutId(id: 0, child: const SizedBox(width: 150.0, height: 100.0)),
LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)),
],
delegate: delegate,
),
@ -225,13 +225,13 @@ void main() {
id: 0,
child: CustomMultiChildLayout(
children: <Widget>[
LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)),
LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)),
LayoutId(id: 0, child: const SizedBox(width: 150.0, height: 100.0)),
LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)),
],
delegate: delegate,
),
),
LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)),
LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)),
],
delegate: delegate,
),

View file

@ -195,7 +195,7 @@ void main() {
expect(target.currentContext.size, const Size(800.0, 600.0));
await tester.pumpWidget(Center(
child: CustomPaint(key: target, child: Container(height: 0.0, width: 0.0)),
child: CustomPaint(key: target, child: const SizedBox(height: 0.0, width: 0.0)),
));
expect(target.currentContext.size, Size.zero);

View file

@ -97,7 +97,7 @@ void main() {
onEnter: (_) { logs.add('enter'); },
onHover: (_) { logs.add('hover'); },
onExit: (_) { logs.add('exit'); },
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
),

View file

@ -384,7 +384,7 @@ void main() {
Widget buildSliver(int i) {
return SliverToBoxAdapter(
key: ValueKey<int>(i),
child: Container(width: 200.0, height: 200.0),
child: const SizedBox(width: 200.0, height: 200.0),
);
}

View file

@ -119,9 +119,9 @@ void main() {
await tester.pumpWidget(
Flow(
delegate: DuplicatePainterOpacityFlowDelegate(1.0),
children: <Widget>[
Container(width: 100.0, height: 100.0),
Container(width: 100.0, height: 100.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
SizedBox(width: 100.0, height: 100.0),
],
),
);
@ -142,8 +142,8 @@ void main() {
await tester.pumpWidget(
Flow(
delegate: OpacityFlowDelegate(opacity),
children: <Widget>[
Container(width: 100.0, height: 100.0),
children: const <Widget>[
SizedBox(width: 100.0, height: 100.0),
],
),
);

View file

@ -559,15 +559,15 @@ void main() {
child: Row(children: <Widget>[
Focus(
focusNode: nodes[0],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
Focus(
focusNode: nodes[1],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
Focus(
focusNode: nodes[2],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
]),
),
@ -578,21 +578,21 @@ void main() {
textDirection: TextDirection.rtl,
child: Focus(
focusNode: nodes[3],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
Directionality(
textDirection: TextDirection.rtl,
child: Focus(
focusNode: nodes[4],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
Directionality(
textDirection: TextDirection.ltr,
child: Focus(
focusNode: nodes[5],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
]),
@ -602,28 +602,28 @@ void main() {
textDirection: TextDirection.ltr,
child: Focus(
focusNode: nodes[6],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
Directionality(
textDirection: TextDirection.rtl,
child: Focus(
focusNode: nodes[7],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
Directionality(
textDirection: TextDirection.rtl,
child: Focus(
focusNode: nodes[8],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
Directionality(
textDirection: TextDirection.ltr,
child: Focus(
focusNode: nodes[9],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
]),
@ -670,7 +670,7 @@ void main() {
// Boxes that all have the same upper left origin corner.
return Focus(
focusNode: nodes[index],
child: Container(width: 10.0 * (index + 1), height: 10.0 * (index + 1)),
child: SizedBox(width: 10.0 * (index + 1), height: 10.0 * (index + 1)),
);
}),
),
@ -697,7 +697,7 @@ void main() {
children: List<Widget>.generate(nodeCount, (int index) {
return Focus(
focusNode: nodes[index],
child: Container(width: 10.0 * (index + 1), height: 10.0 * (index + 1)),
child: SizedBox(width: 10.0 * (index + 1), height: 10.0 * (index + 1)),
);
}),
),
@ -805,7 +805,7 @@ void main() {
nodeCount,
(int index) => Focus(
focusNode: nodes[index],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
),
@ -846,7 +846,7 @@ void main() {
order: NumericFocusOrder(nodeCount - index.toDouble()),
child: Focus(
focusNode: nodes[index],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
),
@ -890,7 +890,7 @@ void main() {
order: LexicalFocusOrder(keys[index]),
child: Focus(
focusNode: nodes[index],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
),
@ -939,21 +939,21 @@ void main() {
order: const NumericFocusOrder(9),
child: Focus(
focusNode: nodes[9],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const NumericFocusOrder(8),
child: Focus(
focusNode: nodes[8],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const NumericFocusOrder(7),
child: Focus(
focusNode: nodes[7],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
]),
@ -968,21 +968,21 @@ void main() {
order: const NumericFocusOrder(4),
child: Focus(
focusNode: nodes[4],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const NumericFocusOrder(5),
child: Focus(
focusNode: nodes[5],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const NumericFocusOrder(6),
child: Focus(
focusNode: nodes[6],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
]),
@ -997,28 +997,28 @@ void main() {
order: const LexicalFocusOrder('D'),
child: Focus(
focusNode: nodes[3],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const LexicalFocusOrder('C'),
child: Focus(
focusNode: nodes[2],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const LexicalFocusOrder('B'),
child: Focus(
focusNode: nodes[1],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
FocusTraversalOrder(
order: const LexicalFocusOrder('A'),
child: Focus(
focusNode: nodes[0],
child: Container(width: 10, height: 10),
child: const SizedBox(width: 10, height: 10),
),
),
]),
@ -1426,9 +1426,9 @@ void main() {
debugLabel: 'lowerLeft',
child: Container(width: 100, height: 100, key: lowerLeftKey),
),
Focus(
const Focus(
debugLabel: 'lowerRight',
child: Container(width: 100, height: 100),
child: SizedBox(width: 100, height: 100),
),
],
),
@ -1466,9 +1466,9 @@ void main() {
debugLabel: 'Scope',
child: Column(
children: <Widget>[
Focus(focusNode: focusTop, child: Container(width: 100, height: 100)),
Focus(focusNode: focusCenter, child: Container(width: 100, height: 100)),
Focus(focusNode: focusBottom, child: Container(width: 100, height: 100)),
Focus(focusNode: focusTop, child: const SizedBox(width: 100, height: 100)),
Focus(focusNode: focusCenter, child: const SizedBox(width: 100, height: 100)),
Focus(focusNode: focusBottom, child: const SizedBox(width: 100, height: 100)),
],
),
),
@ -1490,8 +1490,8 @@ void main() {
debugLabel: 'Scope',
child: Column(
children: <Widget>[
Focus(focusNode: focusTop, child: Container(width: 100, height: 100)),
Focus(focusNode: focusBottom, child: Container(width: 100, height: 100)),
Focus(focusNode: focusTop, child: const SizedBox(width: 100, height: 100)),
Focus(focusNode: focusBottom, child: const SizedBox(width: 100, height: 100)),
],
),
),

View file

@ -40,13 +40,13 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
child: ListView(
key: homeRouteKey,
children: <Widget>[
Container(height: 100.0, width: 100.0),
const SizedBox(height: 100.0, width: 100.0),
Card(child: Hero(
tag: 'a',
transitionOnUserGestures: transitionFromUserGestures,
child: Container(height: 100.0, width: 100.0, key: firstKey),
)),
Container(height: 100.0, width: 100.0),
const SizedBox(height: 100.0, width: 100.0),
FlatButton(
child: const Text('two'),
onPressed: () { Navigator.pushNamed(context, '/two'); },
@ -70,13 +70,13 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
child: const Text('pop'),
onPressed: () { Navigator.pop(context); },
),
Container(height: 150.0, width: 150.0),
const SizedBox(height: 150.0, width: 150.0),
Card(child: Hero(
tag: 'a',
transitionOnUserGestures: transitionFromUserGestures,
child: Container(height: 150.0, width: 150.0, key: secondKey),
)),
Container(height: 150.0, width: 150.0),
const SizedBox(height: 150.0, width: 150.0),
FlatButton(
child: const Text('three'),
onPressed: () { Navigator.push(context, ThreeRoute()); },
@ -96,7 +96,7 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
child: const Text('pop'),
onPressed: () { Navigator.pop(context); },
),
Container(height: 150.0, width: 150.0),
const SizedBox(height: 150.0, width: 150.0),
Card(
child: Padding(
padding: const EdgeInsets.only(left: 50.0),
@ -107,7 +107,7 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
),
),
),
Container(height: 150.0, width: 150.0),
const SizedBox(height: 150.0, width: 150.0),
FlatButton(
child: const Text('three'),
onPressed: () { Navigator.push(context, ThreeRoute()); },
@ -137,9 +137,9 @@ class ThreeRoute extends MaterialPageRoute<void> {
key: routeThreeKey,
child: ListView(
children: <Widget>[
Container(height: 200.0, width: 200.0),
const SizedBox(height: 200.0, width: 200.0),
Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))),
Container(height: 200.0, width: 200.0),
const SizedBox(height: 200.0, width: 200.0),
],
),
);
@ -718,7 +718,7 @@ Future<void> main() async {
return Card(
child: routeIncludesHero
? Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0))
: Container(height: 200.0, width: 200.0),
: const SizedBox(height: 200.0, width: 200.0),
);
},
),

View file

@ -189,7 +189,7 @@ void main() {
Semantics(
label: 'node 1',
selected: true,
child: Container(
child: const SizedBox(
width: 10.0,
height: 10.0,
),
@ -197,7 +197,7 @@ void main() {
Semantics(
label: 'node 2',
selected: true,
child: Container(
child: const SizedBox(
width: 10.0,
height: 10.0,
),
@ -205,7 +205,7 @@ void main() {
Semantics(
label: 'node 3',
selected: true,
child: Container(
child: const SizedBox(
width: 10.0,
height: 10.0,
),

View file

@ -7,15 +7,15 @@ import 'package:flutter/src/painting/basic_types.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
final List<Widget> children = <Widget>[
Container(width: 200.0, height: 150.0),
Container(width: 200.0, height: 150.0),
Container(width: 200.0, height: 150.0),
Container(width: 200.0, height: 150.0),
const List<Widget> children = <Widget>[
SizedBox(width: 200.0, height: 150.0),
SizedBox(width: 200.0, height: 150.0),
SizedBox(width: 200.0, height: 150.0),
SizedBox(width: 200.0, height: 150.0),
];
void expectRects(WidgetTester tester, List<Rect> expected) {
final Finder finder = find.byType(Container);
final Finder finder = find.byType(SizedBox);
finder.precache();
final List<Rect> actual = <Rect>[];
for (int i = 0; i < expected.length; ++i) {

View file

@ -122,7 +122,7 @@ void main() {
await tester.pumpWidget(
Center(
child: Listener(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -152,7 +152,7 @@ void main() {
await tester.pumpWidget(
Center(
child: Listener(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -170,8 +170,8 @@ void main() {
expect(enter, isNotNull);
expect(enter.position, equals(const Offset(400.0, 300.0)));
expect(exit, isNull);
await tester.pumpWidget(Center(
child: Container(
await tester.pumpWidget(const Center(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -284,7 +284,7 @@ void main() {
children: <Widget>[
Listener(
key: key1,
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -294,7 +294,7 @@ void main() {
),
Listener(
key: key2,
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -561,7 +561,7 @@ void main() {
onPointerEnter: (PointerEnterEvent e) => enter.add(e),
onPointerHover: (PointerHoverEvent e) => hover.add(e),
onPointerExit: (PointerExitEvent e) => exit.add(e),
child: Container(
child: const SizedBox(
height: 100.0,
width: 100.0,
),
@ -574,7 +574,7 @@ void main() {
await gesture.addPointer(location: Offset.zero);
addTearDown(() => gesture?.removePointer());
await tester.pumpAndSettle();
await gesture.moveTo(tester.getCenter(find.byType(Container)));
await gesture.moveTo(tester.getCenter(find.byType(SizedBox)));
expect(enter.length, 1);
expect(enter.single.position, const Offset(400.0, 300.0));

View file

@ -119,7 +119,7 @@ void main() {
PointerExitEvent exit;
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -149,7 +149,7 @@ void main() {
PointerExitEvent exit;
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -179,7 +179,7 @@ void main() {
PointerExitEvent exit;
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -214,8 +214,8 @@ void main() {
PointerEnterEvent enter;
PointerHoverEvent move;
PointerExitEvent exit;
await tester.pumpWidget(Center(
child: Container(
await tester.pumpWidget(const Center(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -230,7 +230,7 @@ void main() {
expect(exit, isNull);
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -252,7 +252,7 @@ void main() {
PointerExitEvent exit;
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -269,8 +269,8 @@ void main() {
move = null;
enter = null;
exit = null;
await tester.pumpWidget(Center(
child: Container(
await tester.pumpWidget(const Center(
child: SizedBox(
width: 100.0,
height: 100.0,
),
@ -287,7 +287,7 @@ void main() {
await tester.pumpWidget(Container(
alignment: Alignment.center,
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -306,7 +306,7 @@ void main() {
await tester.pumpWidget(Container(
alignment: Alignment.topLeft,
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -329,7 +329,7 @@ void main() {
await tester.pumpWidget(Container(
alignment: Alignment.center,
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -348,7 +348,7 @@ void main() {
await tester.pumpWidget(Container(
alignment: Alignment.topLeft,
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -471,7 +471,7 @@ void main() {
children: <Widget>[
MouseRegion(
key: key1,
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -481,7 +481,7 @@ void main() {
),
MouseRegion(
key: key2,
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),
@ -842,7 +842,7 @@ void main() {
onEnter: (PointerEnterEvent e) => enter.add(e),
onHover: (PointerHoverEvent e) => hover.add(e),
onExit: (PointerExitEvent e) => exit.add(e),
child: Container(
child: const SizedBox(
height: 100.0,
width: 100.0,
),
@ -855,7 +855,7 @@ void main() {
await gesture.addPointer(location: Offset.zero);
addTearDown(() => gesture?.removePointer());
await tester.pumpAndSettle();
await gesture.moveTo(tester.getCenter(find.byType(Container)));
await gesture.moveTo(tester.getCenter(find.byType(SizedBox)));
expect(enter.length, 1);
expect(enter.single.position, const Offset(400.0, 300.0));
@ -1286,7 +1286,7 @@ void main() {
onEnter: (_) { bottomRegionIsHovered = true; },
onHover: (_) { bottomRegionIsHovered = true; },
onExit: (_) { bottomRegionIsHovered = true; },
child: Container(
child: const SizedBox(
width: 10,
height: 10,
),
@ -1456,7 +1456,7 @@ void main() {
testWidgets('No new frames are scheduled when mouse moves without triggering callbacks', (WidgetTester tester) async {
await tester.pumpWidget(Center(
child: MouseRegion(
child: Container(
child: const SizedBox(
width: 100.0,
height: 100.0,
),

View file

@ -231,7 +231,7 @@ void main() {
textDirection: TextDirection.ltr,
children: <Widget>[
StateMarker(key: key),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));
@ -241,7 +241,7 @@ void main() {
await tester.pumpWidget(Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
StateMarker(key: key),
],
));
@ -253,7 +253,7 @@ void main() {
textDirection: TextDirection.ltr,
children: <Widget>[
StateMarker(key: key),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));
@ -267,9 +267,9 @@ void main() {
await tester.pumpWidget(Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
StateMarker(key: key),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));
@ -280,7 +280,7 @@ void main() {
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0, child: StateMarker(key: key)),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));
@ -290,9 +290,9 @@ void main() {
await tester.pumpWidget(Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
StateMarker(key: key),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));
@ -302,7 +302,7 @@ void main() {
await tester.pumpWidget(Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
Container(width: 100.0, height: 100.0, child: StateMarker(key: key)),
],
));
@ -313,9 +313,9 @@ void main() {
await tester.pumpWidget(Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
StateMarker(key: key),
Container(width: 100.0, height: 100.0),
const SizedBox(width: 100.0, height: 100.0),
],
));

View file

@ -20,8 +20,8 @@ Widget _buildScroller({ List<String> log }) {
}
return false;
},
child: SingleChildScrollView(
child: Container(width: 1000.0, height: 1000.0),
child: const SingleChildScrollView(
child: SizedBox(width: 1000.0, height: 1000.0),
),
);
}

View file

@ -312,14 +312,14 @@ void main() {
children: <Widget>[
Semantics(
value: 'value one',
child: Container(
child: const SizedBox(
height: 10.0,
width: 10.0,
),
),
Semantics(
value: 'value two',
child: Container(
child: const SizedBox(
height: 10.0,
width: 10.0,
),

View file

@ -19,8 +19,8 @@ Shader createShader(Rect bounds) {
void main() {
testWidgets('Can be constructed', (WidgetTester tester) async {
final Widget child = Container(width: 100.0, height: 100.0);
await tester.pumpWidget(ShaderMask(child: child, shaderCallback: createShader));
const Widget child = SizedBox(width: 100.0, height: 100.0);
await tester.pumpWidget(const ShaderMask(child: child, shaderCallback: createShader));
}, skip: isBrowser);
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
@ -37,7 +37,7 @@ void main() {
height: 400.0,
child: ShaderMask(
shaderCallback: recordShaderBounds,
child: Container(width: 100.0, height: 100.0),
child: const SizedBox(width: 100.0, height: 100.0),
),
),
);

View file

@ -44,7 +44,7 @@ void main() {
home: Center(
child: Semantics(
label: 'Hello!',
child: Container(
child: const SizedBox(
width: 10.0,
height: 10.0,
),

View file

@ -581,8 +581,9 @@ void main() {
children: List<Widget>.generate(10, (int y) {
return Row(
children: children[y] = List<Widget>.generate(10, (int x) {
return Container(
height: 100.0,
// nonconst is used below to avoid const constructor and to force a new instance
return SizedBox(
height: nonconst(100.0),
width: 100.0,
);
}),

View file

@ -412,15 +412,15 @@ void main() {
textDirection: TextDirection.ltr,
child: Center(
child: Stack(
children: <Widget>[
Container(
children: const <Widget>[
SizedBox(
width: 100.0,
height: 100.0,
),
Positioned(
top: 0.0,
left: 0.0,
child: Container(
child: SizedBox(
width: 200.0,
height: 200.0,
),
@ -442,15 +442,15 @@ void main() {
child: Center(
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
children: const <Widget>[
SizedBox(
width: 100.0,
height: 100.0,
),
Positioned(
top: 0.0,
left: 0.0,
child: Container(
child: SizedBox(
width: 200.0,
height: 200.0,
),