Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
75ee4403
Unverified
Commit
75ee4403
authored
Aug 19, 2022
by
Tomasz Gucio
Committed by
GitHub
Aug 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace empty Container with const SizedBox (#108672)
parent
30baf95a
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
42 additions
and
33 deletions
+42
-33
context_menu.dart
packages/flutter/lib/src/cupertino/context_menu.dart
+2
-2
desktop_text_selection.dart
...ges/flutter/lib/src/cupertino/desktop_text_selection.dart
+2
-2
dialog.dart
packages/flutter/lib/src/cupertino/dialog.dart
+1
-1
refresh.dart
packages/flutter/lib/src/cupertino/refresh.dart
+1
-1
tab_scaffold.dart
packages/flutter/lib/src/cupertino/tab_scaffold.dart
+1
-1
text_selection.dart
packages/flutter/lib/src/cupertino/text_selection.dart
+3
-3
about.dart
packages/flutter/lib/src/material/about.dart
+1
-1
data_table.dart
packages/flutter/lib/src/material/data_table.dart
+1
-1
desktop_text_selection.dart
...ages/flutter/lib/src/material/desktop_text_selection.dart
+2
-2
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+1
-1
ink_decoration.dart
packages/flutter/lib/src/material/ink_decoration.dart
+1
-1
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+1
-1
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+1
-1
text_selection.dart
packages/flutter/lib/src/material/text_selection.dart
+1
-1
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+1
-1
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+3
-3
localizations.dart
packages/flutter/lib/src/widgets/localizations.dart
+1
-2
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+3
-3
ink_paint_test.dart
packages/flutter/test/material/ink_paint_test.dart
+15
-5
No files found.
packages/flutter/lib/src/cupertino/context_menu.dart
View file @
75ee4403
...
...
@@ -738,8 +738,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
// buildTransitions as child, the idea being that buildTransitions will
// animate the entire page into the scene. In the case of _ContextMenuRoute,
// two individual pieces of the page are animated into the scene in
// buildTransitions, and a
Container
is returned here.
return
Container
();
// buildTransitions, and a
SizedBox.shrink()
is returned here.
return
const
SizedBox
.
shrink
();
}
@override
...
...
packages/flutter/lib/src/cupertino/desktop_text_selection.dart
View file @
75ee4403
...
...
@@ -153,7 +153,7 @@ class _CupertinoDesktopTextSelectionControlsToolbarState extends State<_Cupertin
Widget
build
(
BuildContext
context
)
{
// Don't render the menu until the state of the clipboard is known.
if
(
widget
.
handlePaste
!=
null
&&
widget
.
clipboardStatus
?.
value
==
ClipboardStatus
.
unknown
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
assert
(
debugCheckHasMediaQuery
(
context
));
...
...
@@ -203,7 +203,7 @@ class _CupertinoDesktopTextSelectionControlsToolbarState extends State<_Cupertin
// If there is no option available, build an empty widget.
if
(
items
.
isEmpty
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
return
_CupertinoDesktopTextSelectionToolbar
(
...
...
packages/flutter/lib/src/cupertino/dialog.dart
View file @
75ee4403
...
...
@@ -1389,7 +1389,7 @@ class _CupertinoAlertContentSection extends StatelessWidget {
if
(
title
==
null
&&
message
==
null
)
{
return
SingleChildScrollView
(
controller:
scrollController
,
child:
const
SizedBox
(
width:
0.0
,
height:
0.0
),
child:
const
SizedBox
.
shrink
(
),
);
}
...
...
packages/flutter/lib/src/cupertino/refresh.dart
View file @
75ee4403
...
...
@@ -422,7 +422,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
return
CupertinoActivityIndicator
(
radius:
radius
*
percentageComplete
);
case
RefreshIndicatorMode
.
inactive
:
// Anything else doesn't show anything.
return
Container
();
return
const
SizedBox
.
shrink
();
}
}
...
...
packages/flutter/lib/src/cupertino/tab_scaffold.dart
View file @
75ee4403
...
...
@@ -504,7 +504,7 @@ class _TabSwitchingViewState extends State<_TabSwitchingView> {
child:
FocusScope
(
node:
tabFocusNodes
[
index
],
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
shouldBuildTab
[
index
]
?
widget
.
tabBuilder
(
context
,
index
)
:
Container
();
return
shouldBuildTab
[
index
]
?
widget
.
tabBuilder
(
context
,
index
)
:
const
SizedBox
.
shrink
();
}),
),
),
...
...
packages/flutter/lib/src/cupertino/text_selection.dart
View file @
75ee4403
...
...
@@ -82,7 +82,7 @@ class _CupertinoTextSelectionControlsToolbarState extends State<_CupertinoTextSe
Widget
build
(
BuildContext
context
)
{
// Don't render the menu until the state of the clipboard is known.
if
(
widget
.
handlePaste
!=
null
&&
widget
.
clipboardStatus
?.
value
==
ClipboardStatus
.
unknown
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
assert
(
debugCheckHasMediaQuery
(
context
));
...
...
@@ -147,7 +147,7 @@ class _CupertinoTextSelectionControlsToolbarState extends State<_CupertinoTextSe
// If there is no option available, build an empty widget.
if
(
items
.
isEmpty
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
return
CupertinoTextSelectionToolbar
(
...
...
@@ -266,7 +266,7 @@ class CupertinoTextSelectionControls extends TextSelectionControls {
);
// iOS doesn't draw anything for collapsed selections.
case
TextSelectionHandleType
.
collapsed
:
return
const
SizedBox
();
return
const
SizedBox
.
shrink
();
}
}
...
...
packages/flutter/lib/src/material/about.dart
View file @
75ee4403
...
...
@@ -1451,7 +1451,7 @@ class _DetailView extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
if
(
_arguments
==
null
)
{
return
Container
();
return
const
SizedBox
.
shrink
();
}
final
double
screenHeight
=
MediaQuery
.
of
(
context
).
size
.
height
;
final
double
minHeight
=
(
screenHeight
-
kToolbarHeight
)
/
screenHeight
;
...
...
packages/flutter/lib/src/material/data_table.dart
View file @
75ee4403
...
...
@@ -237,7 +237,7 @@ class DataCell {
})
:
assert
(
child
!=
null
);
/// A cell that has no content and has zero width and height.
static
const
DataCell
empty
=
DataCell
(
SizedBox
(
width:
0.0
,
height:
0.0
));
static
const
DataCell
empty
=
DataCell
(
SizedBox
.
shrink
(
));
/// The data for the row.
///
...
...
packages/flutter/lib/src/material/desktop_text_selection.dart
View file @
75ee4403
...
...
@@ -153,7 +153,7 @@ class _DesktopTextSelectionControlsToolbarState extends State<_DesktopTextSelect
// Don't render the menu until the state of the clipboard is known.
if
(
widget
.
handlePaste
!=
null
&&
widget
.
clipboardStatus
?.
value
==
ClipboardStatus
.
unknown
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
final
MediaQueryData
mediaQuery
=
MediaQuery
.
of
(
context
);
...
...
@@ -196,7 +196,7 @@ class _DesktopTextSelectionControlsToolbarState extends State<_DesktopTextSelect
// If there is no option available, build an empty widget.
if
(
items
.
isEmpty
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
return
_DesktopTextSelectionToolbar
(
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
75ee4403
...
...
@@ -1424,7 +1424,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
// display the hint or nothing at all.
final
Widget
innerItemsWidget
;
if
(
items
.
isEmpty
)
{
innerItemsWidget
=
Container
();
innerItemsWidget
=
const
SizedBox
.
shrink
();
}
else
{
innerItemsWidget
=
IndexedStack
(
index:
_selectedIndex
??
hintIndex
,
...
...
packages/flutter/lib/src/material/ink_decoration.dart
View file @
75ee4403
...
...
@@ -292,7 +292,7 @@ class _InkState extends State<Ink> {
_ink
!.
decoration
=
widget
.
decoration
;
_ink
!.
configuration
=
createLocalImageConfiguration
(
context
);
}
return
widget
.
child
??
Container
();
return
widget
.
child
??
const
SizedBox
();
}
@override
...
...
packages/flutter/lib/src/material/input_decorator.dart
View file @
75ee4403
...
...
@@ -319,7 +319,7 @@ class _HelperError extends StatefulWidget {
class
_HelperErrorState
extends
State
<
_HelperError
>
with
SingleTickerProviderStateMixin
{
// If the height of this widget and the counter are zero ("empty") at
// layout time, no space is allocated for the subtext.
static
const
Widget
empty
=
SizedBox
();
static
const
Widget
empty
=
SizedBox
.
shrink
();
late
AnimationController
_controller
;
Widget
?
_helper
;
...
...
packages/flutter/lib/src/material/stepper.dart
View file @
75ee4403
...
...
@@ -641,7 +641,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
child:
widget
.
steps
[
index
].
label
!,
);
}
return
const
SizedBox
();
return
const
SizedBox
.
shrink
();
}
Widget
_buildVerticalHeader
(
int
index
)
{
...
...
packages/flutter/lib/src/material/text_selection.dart
View file @
75ee4403
...
...
@@ -250,7 +250,7 @@ class _TextSelectionControlsToolbarState extends State<_TextSelectionControlsToo
// If there is no option available, build an empty widget.
if
(
itemDatas
.
isEmpty
)
{
return
const
SizedBox
(
width:
0.0
,
height:
0.0
);
return
const
SizedBox
.
shrink
(
);
}
return
TextSelectionToolbar
(
...
...
packages/flutter/lib/src/material/tooltip.dart
View file @
75ee4403
...
...
@@ -696,7 +696,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
// the empty black container so just return the wrapped child as is or
// empty container if child is not specified.
if
(
_tooltipMessage
.
isEmpty
)
{
return
widget
.
child
??
const
SizedBox
();
return
widget
.
child
??
const
SizedBox
.
shrink
();
}
assert
(
debugCheckHasOverlay
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
75ee4403
...
...
@@ -3829,10 +3829,10 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
final
int
placeholderLocation
=
_value
.
text
.
length
-
_placeholderLocation
;
if
(
_isMultiline
)
{
// The zero size placeholder here allows the line to break and keep the caret on the first line.
placeholders
.
add
(
const
_ScribblePlaceholder
(
child:
SizedBox
(),
size:
Size
.
zero
));
placeholders
.
add
(
_ScribblePlaceholder
(
child:
const
SizedBox
(),
size:
Size
(
renderEditable
.
size
.
width
,
0.0
)));
placeholders
.
add
(
const
_ScribblePlaceholder
(
child:
SizedBox
.
shrink
(),
size:
Size
.
zero
));
placeholders
.
add
(
_ScribblePlaceholder
(
child:
const
SizedBox
.
shrink
(),
size:
Size
(
renderEditable
.
size
.
width
,
0.0
)));
}
else
{
placeholders
.
add
(
const
_ScribblePlaceholder
(
child:
SizedBox
(),
size:
Size
(
100.0
,
0.0
)));
placeholders
.
add
(
const
_ScribblePlaceholder
(
child:
SizedBox
.
shrink
(),
size:
Size
(
100.0
,
0.0
)));
}
return
TextSpan
(
style:
widget
.
style
,
children:
<
InlineSpan
>[
TextSpan
(
text:
_value
.
text
.
substring
(
0
,
placeholderLocation
)),
...
...
packages/flutter/lib/src/widgets/localizations.dart
View file @
75ee4403
...
...
@@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/rendering.dart'
;
import
'basic.dart'
;
import
'container.dart'
;
import
'debug.dart'
;
import
'framework.dart'
;
...
...
@@ -598,7 +597,7 @@ class _LocalizationsState extends State<Localizations> {
@override
Widget
build
(
BuildContext
context
)
{
if
(
_locale
==
null
)
{
return
Container
();
return
const
SizedBox
.
shrink
();
}
return
Semantics
(
textDirection:
_textDirection
,
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
75ee4403
...
...
@@ -1156,7 +1156,7 @@ class SelectionOverlay {
final
Widget
handle
;
final
TextSelectionControls
?
selectionControls
=
this
.
selectionControls
;
if
(
selectionControls
==
null
)
{
handle
=
Container
();
handle
=
const
SizedBox
.
shrink
();
}
else
{
handle
=
_SelectionHandleOverlay
(
type:
_startHandleType
,
...
...
@@ -1183,7 +1183,7 @@ class SelectionOverlay {
final
TextSelectionControls
?
selectionControls
=
this
.
selectionControls
;
if
(
selectionControls
==
null
||
_startHandleType
==
TextSelectionHandleType
.
collapsed
)
{
// Hide the second handle when collapsed.
handle
=
Container
();
handle
=
const
SizedBox
.
shrink
();
}
else
{
handle
=
_SelectionHandleOverlay
(
type:
_endHandleType
,
...
...
@@ -1207,7 +1207,7 @@ class SelectionOverlay {
Widget
_buildToolbar
(
BuildContext
context
)
{
if
(
selectionControls
==
null
)
{
return
Container
();
return
const
SizedBox
.
shrink
();
}
final
RenderBox
renderBox
=
this
.
context
.
findRenderObject
()!
as
RenderBox
;
...
...
packages/flutter/test/material/ink_paint_test.dart
View file @
75ee4403
...
...
@@ -9,14 +9,19 @@ import 'package:flutter_test/flutter_test.dart';
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
testWidgets
(
'The Ink widget renders a
Container
by default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'The Ink widget renders a
SizedBox
by default'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Material
(
child:
Ink
(),
),
);
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
height
,
600.0
);
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
width
,
800.0
);
Finder
sizedBox
=
find
.
descendant
(
of:
find
.
byType
(
Ink
),
matching:
find
.
byType
(
SizedBox
),
);
expect
(
sizedBox
,
findsOneWidget
);
expect
(
tester
.
getSize
(
sizedBox
).
height
,
600.0
);
expect
(
tester
.
getSize
(
sizedBox
).
width
,
800.0
);
const
double
height
=
150.0
;
const
double
width
=
200.0
;
...
...
@@ -31,8 +36,13 @@ void main() {
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
height
,
height
);
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
width
,
width
);
sizedBox
=
find
.
descendant
(
of:
find
.
byType
(
Ink
),
matching:
find
.
byType
(
SizedBox
),
);
expect
(
sizedBox
,
findsNWidgets
(
2
));
expect
(
tester
.
getSize
(
sizedBox
.
at
(
0
)).
height
,
height
);
expect
(
tester
.
getSize
(
sizedBox
.
at
(
0
)).
width
,
width
);
});
testWidgets
(
'The InkWell widget renders an ink splash'
,
(
WidgetTester
tester
)
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment