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
60b9d154
Unverified
Commit
60b9d154
authored
Mar 14, 2020
by
Ayush Bherwani
Committed by
GitHub
Mar 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RaisedButton] Added padding property to RaisedButton.icon (#52393)
parent
8e6e15f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
raised_button.dart
packages/flutter/lib/src/material/raised_button.dart
+3
-0
raised_button_test.dart
packages/flutter/test/material/raised_button_test.dart
+40
-0
No files found.
packages/flutter/lib/src/material/raised_button.dart
View file @
60b9d154
...
@@ -202,6 +202,7 @@ class RaisedButton extends MaterialButton {
...
@@ -202,6 +202,7 @@ class RaisedButton extends MaterialButton {
Clip
clipBehavior
,
Clip
clipBehavior
,
FocusNode
focusNode
,
FocusNode
focusNode
,
bool
autofocus
,
bool
autofocus
,
EdgeInsetsGeometry
padding
,
MaterialTapTargetSize
materialTapTargetSize
,
MaterialTapTargetSize
materialTapTargetSize
,
Duration
animationDuration
,
Duration
animationDuration
,
@required
Widget
icon
,
@required
Widget
icon
,
...
@@ -278,6 +279,7 @@ class _RaisedButtonWithIcon extends RaisedButton with MaterialButtonWithIconMixi
...
@@ -278,6 +279,7 @@ class _RaisedButtonWithIcon extends RaisedButton with MaterialButtonWithIconMixi
Clip
clipBehavior
=
Clip
.
none
,
Clip
clipBehavior
=
Clip
.
none
,
FocusNode
focusNode
,
FocusNode
focusNode
,
bool
autofocus
=
false
,
bool
autofocus
=
false
,
EdgeInsetsGeometry
padding
,
MaterialTapTargetSize
materialTapTargetSize
,
MaterialTapTargetSize
materialTapTargetSize
,
Duration
animationDuration
,
Duration
animationDuration
,
@required
Widget
icon
,
@required
Widget
icon
,
...
@@ -311,6 +313,7 @@ class _RaisedButtonWithIcon extends RaisedButton with MaterialButtonWithIconMixi
...
@@ -311,6 +313,7 @@ class _RaisedButtonWithIcon extends RaisedButton with MaterialButtonWithIconMixi
clipBehavior:
clipBehavior
,
clipBehavior:
clipBehavior
,
focusNode:
focusNode
,
focusNode:
focusNode
,
autofocus:
autofocus
,
autofocus:
autofocus
,
padding:
padding
,
materialTapTargetSize:
materialTapTargetSize
,
materialTapTargetSize:
materialTapTargetSize
,
animationDuration:
animationDuration
,
animationDuration:
animationDuration
,
child:
Row
(
child:
Row
(
...
...
packages/flutter/test/material/raised_button_test.dart
View file @
60b9d154
...
@@ -617,6 +617,46 @@ void main() {
...
@@ -617,6 +617,46 @@ void main() {
expect
(
box
.
size
,
equals
(
const
Size
(
76
,
36
)));
expect
(
box
.
size
,
equals
(
const
Size
(
76
,
36
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
});
});
testWidgets
(
'RaisedButton.icon responds to applied padding'
,
(
WidgetTester
tester
)
async
{
const
Key
buttonKey
=
Key
(
'test'
);
const
Key
labelKey
=
Key
(
'label'
);
await
tester
.
pumpWidget
(
// When textDirection is set to TextDirection.ltr, the label appears on the
// right side of the icon. This is important in determining whether the
// horizontal padding is applied correctly later on
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
RaisedButton
.
icon
(
icon:
const
Icon
(
Icons
.
add
),
padding:
const
EdgeInsets
.
fromLTRB
(
16
,
5
,
10
,
12
),
key:
buttonKey
,
onPressed:
()
{},
label:
const
Text
(
'Hello'
,
key:
labelKey
,
),
),
),
),
),
);
final
Rect
paddingRect
=
tester
.
getRect
(
find
.
byType
(
Padding
));
final
Rect
labelRect
=
tester
.
getRect
(
find
.
byKey
(
labelKey
));
final
Rect
iconRect
=
tester
.
getRect
(
find
.
byType
(
Icon
));
// The right padding should be applied on the right of the label, whereas the
// left padding should be applied on the left side of the icon.
expect
(
paddingRect
.
right
,
labelRect
.
right
+
10
);
expect
(
paddingRect
.
left
,
iconRect
.
left
-
16
);
// Use the taller widget to check the top and bottom padding.
final
Rect
tallerWidget
=
iconRect
.
height
>
labelRect
.
height
?
iconRect
:
labelRect
;
expect
(
paddingRect
.
top
,
tallerWidget
.
top
-
5
);
expect
(
paddingRect
.
bottom
,
tallerWidget
.
bottom
+
12
);
});
}
}
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
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