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
c29009b3
Unverified
Commit
c29009b3
authored
Jul 09, 2020
by
Max Weber
Committed by
GitHub
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the materialTapTargetSize to the OutlineButton Constructor (#61086)
parent
0268096b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
outline_button.dart
packages/flutter/lib/src/material/outline_button.dart
+9
-0
outline_button_test.dart
packages/flutter/test/material/outline_button_test.dart
+91
-0
No files found.
packages/flutter/lib/src/material/outline_button.dart
View file @
c29009b3
...
...
@@ -85,6 +85,7 @@ class OutlineButton extends MaterialButton {
Clip
clipBehavior
=
Clip
.
none
,
FocusNode
focusNode
,
bool
autofocus
=
false
,
MaterialTapTargetSize
materialTapTargetSize
,
Widget
child
,
})
:
assert
(
highlightElevation
==
null
||
highlightElevation
>=
0.0
),
assert
(
clipBehavior
!=
null
),
...
...
@@ -108,6 +109,7 @@ class OutlineButton extends MaterialButton {
shape:
shape
,
clipBehavior:
clipBehavior
,
focusNode:
focusNode
,
materialTapTargetSize:
materialTapTargetSize
,
autofocus:
autofocus
,
child:
child
,
);
...
...
@@ -143,6 +145,7 @@ class OutlineButton extends MaterialButton {
Clip
clipBehavior
,
FocusNode
focusNode
,
bool
autofocus
,
MaterialTapTargetSize
materialTapTargetSize
,
@required
Widget
icon
,
@required
Widget
label
,
})
=
_OutlineButtonWithIcon
;
...
...
@@ -203,6 +206,7 @@ class OutlineButton extends MaterialButton {
shape:
buttonTheme
.
getShape
(
this
),
clipBehavior:
clipBehavior
,
focusNode:
focusNode
,
materialTapTargetSize:
materialTapTargetSize
,
child:
child
,
);
}
...
...
@@ -244,6 +248,7 @@ class _OutlineButtonWithIcon extends OutlineButton with MaterialButtonWithIconMi
Clip
clipBehavior
=
Clip
.
none
,
FocusNode
focusNode
,
bool
autofocus
=
false
,
MaterialTapTargetSize
materialTapTargetSize
,
@required
Widget
icon
,
@required
Widget
label
,
})
:
assert
(
highlightElevation
==
null
||
highlightElevation
>=
0.0
),
...
...
@@ -274,6 +279,7 @@ class _OutlineButtonWithIcon extends OutlineButton with MaterialButtonWithIconMi
clipBehavior:
clipBehavior
,
focusNode:
focusNode
,
autofocus:
autofocus
,
materialTapTargetSize:
materialTapTargetSize
,
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
...
...
@@ -311,6 +317,7 @@ class _OutlineButton extends StatefulWidget {
this
.
focusNode
,
this
.
autofocus
=
false
,
this
.
child
,
this
.
materialTapTargetSize
,
})
:
assert
(
highlightElevation
!=
null
&&
highlightElevation
>=
0.0
),
assert
(
highlightedBorderColor
!=
null
),
assert
(
clipBehavior
!=
null
),
...
...
@@ -340,6 +347,7 @@ class _OutlineButton extends StatefulWidget {
final
FocusNode
focusNode
;
final
bool
autofocus
;
final
Widget
child
;
final
MaterialTapTargetSize
materialTapTargetSize
;
bool
get
enabled
=>
onPressed
!=
null
||
onLongPress
!=
null
;
...
...
@@ -489,6 +497,7 @@ class _OutlineButtonState extends State<_OutlineButton> with SingleTickerProvide
clipBehavior:
widget
.
clipBehavior
,
focusNode:
widget
.
focusNode
,
animationDuration:
_kElevationDuration
,
materialTapTargetSize:
widget
.
materialTapTargetSize
,
child:
widget
.
child
,
);
},
...
...
packages/flutter/test/material/outline_button_test.dart
View file @
c29009b3
...
...
@@ -1043,6 +1043,97 @@ void main() {
_checkPhysicalLayer
(
buttonElement
,
fillColor
.
withAlpha
(
0x00
));
});
testWidgets
(
'OutlineButton respects the provided materialTapTargetSize'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
OutlineButton
(
materialTapTargetSize:
MaterialTapTargetSize
.
padded
,
onPressed:
()
{},
child:
const
SizedBox
(
width:
50.0
,
height:
8.0
),
),
),
),
),
);
// Default Width of OutlineButton with MaterialTapTargetSize (88)
expect
(
tester
.
getSize
(
find
.
byType
(
OutlineButton
)),
const
Size
(
88.0
,
48.0
));
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
OutlineButton
(
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
onPressed:
()
{},
child:
const
SizedBox
(
width:
50.0
,
height:
8.0
),
),
),
),
),
);
// Default Width of OutlineButton with MaterialTapTargetSize (88)
expect
(
tester
.
getSize
(
find
.
byType
(
OutlineButton
)),
const
Size
(
88.0
,
36.0
));
final
LocalKey
key1
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
OutlineButton
.
icon
(
key:
key1
,
materialTapTargetSize:
MaterialTapTargetSize
.
padded
,
icon:
const
Icon
(
Icons
.
add_alarm
),
label:
const
SizedBox
(
width:
50.0
,
height:
8.0
),
onPressed:
()
{
},
),
),
),
),
);
final
Size
addAlarmIconSize
=
tester
.
getSize
(
find
.
byIcon
(
Icons
.
add_alarm
));
// The expected width is the sum of:
// the width of the icon
// the gap between the icon and the label (8)
// the width of the label (50)
// the horizontal padding: start (12), end (16)
expect
(
tester
.
getSize
(
find
.
byKey
(
key1
)),
Size
(
86
+
addAlarmIconSize
.
width
,
48.0
));
final
LocalKey
key2
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
OutlineButton
.
icon
(
key:
key2
,
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
icon:
const
Icon
(
Icons
.
add
),
label:
const
SizedBox
(
width:
50.0
,
height:
8.0
),
onPressed:
()
{
},
),
),
),
),
);
// The expected width is the sum of:
// the width of the icon
// the gap between the icon and the label (8)
// the width of the label (50)
// the horizontal padding: start (12), end (16)
final
Size
addIconSize
=
tester
.
getSize
(
find
.
byIcon
(
Icons
.
add
));
expect
(
tester
.
getSize
(
find
.
byKey
(
key2
)),
Size
(
86
+
addIconSize
.
width
,
36.0
));
});
testWidgets
(
'OutlineButton onPressed and onLongPress callbacks are distinctly recognized'
,
(
WidgetTester
tester
)
async
{
bool
didPressButton
=
false
;
bool
didLongPressButton
=
false
;
...
...
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