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
b5d521f9
Unverified
Commit
b5d521f9
authored
Apr 21, 2021
by
Hans Muller
Committed by
GitHub
Apr 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VisualDensity should not reduce ButtonStyleButton horizontal padding (#79680)
parent
9699b3bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
19 deletions
+27
-19
button_style_button.dart
packages/flutter/lib/src/material/button_style_button.dart
+9
-8
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+2
-2
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+2
-2
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+2
-2
sliver_fill_remaining_test.dart
...ages/flutter/test/widgets/sliver_fill_remaining_test.dart
+12
-5
No files found.
packages/flutter/lib/src/material/button_style_button.dart
View file @
b5d521f9
...
...
@@ -312,14 +312,15 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
}
}
final
EdgeInsetsGeometry
padding
=
resolvedPadding
!.
add
(
EdgeInsets
.
only
(
left:
densityAdjustment
.
dx
,
top:
densityAdjustment
.
dy
,
right:
densityAdjustment
.
dx
,
bottom:
densityAdjustment
.
dy
,
),
).
clamp
(
EdgeInsets
.
zero
,
EdgeInsetsGeometry
.
infinity
);
// Per the Material Design team: don't allow the VisualDensity
// adjustment to reduce the width of the left/right padding. If we
// did, VisualDensity.compact, the default for desktop/web, would
// reduce the horizontal padding to zero.
final
double
dy
=
densityAdjustment
.
dy
;
final
double
dx
=
math
.
max
(
0
,
densityAdjustment
.
dx
);
final
EdgeInsetsGeometry
padding
=
resolvedPadding
!
.
add
(
EdgeInsets
.
fromLTRB
(
dx
,
dy
,
dx
,
dy
))
.
clamp
(
EdgeInsets
.
zero
,
EdgeInsetsGeometry
.
infinity
);
// If an opaque button's background is becoming translucent while its
// elevation is changing, change the elevation first. Material implicitly
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
b5d521f9
...
...
@@ -649,7 +649,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
));
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
1
08
,
100
)));
expect
(
box
.
size
,
equals
(
const
Size
(
1
32
,
100
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
350
,
250
,
450
,
350
)));
await
buildTest
(
VisualDensity
.
standard
,
useText:
true
);
...
...
@@ -667,7 +667,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
),
useText:
true
);
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
76
,
36
)));
expect
(
box
.
size
,
equals
(
const
Size
(
88
,
36
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
});
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
b5d521f9
...
...
@@ -956,7 +956,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
));
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
1
08
,
100
)));
expect
(
box
.
size
,
equals
(
const
Size
(
1
32
,
100
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
350
,
250
,
450
,
350
)));
await
buildTest
(
VisualDensity
.
standard
,
useText:
true
);
...
...
@@ -974,7 +974,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
),
useText:
true
);
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
64
,
36
)));
expect
(
box
.
size
,
equals
(
const
Size
(
88
,
36
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
});
...
...
packages/flutter/test/material/text_button_test.dart
View file @
b5d521f9
...
...
@@ -739,7 +739,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
));
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
1
00
,
100
)));
expect
(
box
.
size
,
equals
(
const
Size
(
1
16
,
100
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
350
,
250
,
450
,
350
)));
await
buildTest
(
VisualDensity
.
standard
,
useText:
true
);
...
...
@@ -757,7 +757,7 @@ void main() {
await
buildTest
(
const
VisualDensity
(
horizontal:
-
3.0
,
vertical:
-
3.0
),
useText:
true
);
await
tester
.
pumpAndSettle
();
childRect
=
tester
.
getRect
(
find
.
byKey
(
childKey
));
expect
(
box
.
size
,
equals
(
const
Size
(
56
,
36
)));
expect
(
box
.
size
,
equals
(
const
Size
(
72
,
36
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
});
...
...
packages/flutter/test/widgets/sliver_fill_remaining_test.dart
View file @
b5d521f9
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -322,10 +324,11 @@ void main() {
expect
(
tester
.
getCenter
(
logo
),
Offset
(
400.0
,
351.0
-
density
.
vertical
*
2.0
));
// Also check that the button alignment is true to expectations
// Buttons do not decrease their horizontal padding per the VisualDensity.
final
Finder
button
=
find
.
byType
(
ElevatedButton
);
expect
(
tester
.
renderObject
<
RenderBox
>(
button
).
size
,
Size
(
116.0
+
density
.
horizontal
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
Size
(
116.0
+
math
.
max
(
0
,
density
.
horizontal
)
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
);
expect
(
tester
.
getBottomLeft
(
button
).
dy
,
equals
(
600.0
));
expect
(
tester
.
getCenter
(
button
).
dx
,
equals
(
400.0
));
...
...
@@ -344,7 +347,8 @@ void main() {
expect
(
tester
.
getCenter
(
logo
).
dy
,
lessThan
(
351.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
button
).
size
,
Size
(
116.0
+
density
.
horizontal
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size
(
116.0
+
math
.
max
(
0
,
density
.
horizontal
)
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
);
expect
(
tester
.
getBottomLeft
(
button
).
dy
,
lessThan
(
600.0
));
expect
(
tester
.
getCenter
(
button
).
dx
,
equals
(
400.0
));
...
...
@@ -592,10 +596,11 @@ void main() {
expect
(
tester
.
getCenter
(
logo
),
Offset
(
400.0
,
351.0
-
density
.
vertical
*
2.0
));
// Also check that the button alignment is true to expectations.
// Buttons do not decrease their horizontal padding per the VisualDensity.
final
Finder
button
=
find
.
byType
(
ElevatedButton
);
expect
(
tester
.
renderObject
<
RenderBox
>(
button
).
size
,
Size
(
116.0
+
density
.
horizontal
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
Size
(
116.0
+
math
.
max
(
0
,
density
.
horizontal
)
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
);
expect
(
tester
.
getBottomLeft
(
button
).
dy
,
equals
(
600.0
));
expect
(
tester
.
getCenter
(
button
).
dx
,
equals
(
400.0
));
...
...
@@ -616,7 +621,8 @@ void main() {
expect
(
tester
.
getCenter
(
logo
).
dy
,
lessThan
(
351.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
button
).
size
,
Size
(
116.0
+
density
.
horizontal
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size
(
116.0
+
math
.
max
(
0
,
density
.
horizontal
)
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
);
expect
(
tester
.
getBottomLeft
(
button
).
dy
,
equals
(
600.0
));
expect
(
tester
.
getCenter
(
button
).
dx
,
equals
(
400.0
));
...
...
@@ -635,7 +641,8 @@ void main() {
expect
(
tester
.
getCenter
(
logo
),
Offset
(
400.0
,
351.0
-
density
.
vertical
*
2.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
button
).
size
,
Size
(
116.0
+
density
.
horizontal
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size
(
116.0
+
math
.
max
(
0
,
density
.
horizontal
)
*
8.0
,
48.0
+
density
.
vertical
*
4.0
),
);
expect
(
tester
.
getBottomLeft
(
button
).
dy
,
equals
(
600.0
));
expect
(
tester
.
getCenter
(
button
).
dx
,
equals
(
400.0
));
...
...
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