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
5142a304
Unverified
Commit
5142a304
authored
Jul 24, 2020
by
Pedro Massango
Committed by
GitHub
Jul 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add minWidth and height parameter into FlatButton widget (#61664)
parent
5fa5701d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
1 deletion
+74
-1
flat_button.dart
packages/flutter/lib/src/material/flat_button.dart
+14
-1
flat_button_test.dart
packages/flutter/test/material/flat_button_test.dart
+60
-0
No files found.
packages/flutter/lib/src/material/flat_button.dart
View file @
5142a304
...
...
@@ -126,10 +126,14 @@ class FlatButton extends MaterialButton {
bool
autofocus
=
false
,
MaterialTapTargetSize
materialTapTargetSize
,
@required
Widget
child
,
double
height
,
double
minWidth
,
})
:
assert
(
clipBehavior
!=
null
),
assert
(
autofocus
!=
null
),
super
(
key:
key
,
height:
height
,
minWidth:
minWidth
,
onPressed:
onPressed
,
onLongPress:
onLongPress
,
onHighlightChanged:
onHighlightChanged
,
...
...
@@ -185,6 +189,8 @@ class FlatButton extends MaterialButton {
MaterialTapTargetSize
materialTapTargetSize
,
@required
Widget
icon
,
@required
Widget
label
,
double
minWidth
,
double
height
,
})
=
_FlatButtonWithIcon
;
@override
...
...
@@ -209,7 +215,10 @@ class FlatButton extends MaterialButton {
disabledElevation:
buttonTheme
.
getDisabledElevation
(
this
),
padding:
buttonTheme
.
getPadding
(
this
),
visualDensity:
visualDensity
??
theme
.
visualDensity
,
constraints:
buttonTheme
.
getConstraints
(
this
),
constraints:
buttonTheme
.
getConstraints
(
this
).
copyWith
(
minWidth:
minWidth
,
minHeight:
height
,
),
shape:
buttonTheme
.
getShape
(
this
),
clipBehavior:
clipBehavior
,
focusNode:
focusNode
,
...
...
@@ -250,6 +259,8 @@ class _FlatButtonWithIcon extends FlatButton with MaterialButtonWithIconMixin {
MaterialTapTargetSize
materialTapTargetSize
,
@required
Widget
icon
,
@required
Widget
label
,
double
minWidth
,
double
height
,
})
:
assert
(
icon
!=
null
),
assert
(
label
!=
null
),
assert
(
clipBehavior
!=
null
),
...
...
@@ -284,6 +295,8 @@ class _FlatButtonWithIcon extends FlatButton with MaterialButtonWithIconMixin {
label
,
],
),
minWidth:
minWidth
,
height:
height
,
);
}
packages/flutter/test/material/flat_button_test.dart
View file @
5142a304
...
...
@@ -824,6 +824,66 @@ void main() {
expect
(
box
.
size
,
equals
(
const
Size
(
76
,
36
)));
expect
(
childRect
,
equals
(
const
Rect
.
fromLTRB
(
372.0
,
293.0
,
428.0
,
307.0
)));
});
testWidgets
(
'FlatButton height parameter is used when provided'
,
(
WidgetTester
tester
)
async
{
const
double
buttonHeight
=
100
;
const
double
buttonDefaultMinHeight
=
36.0
;
Future
<
void
>
buildWidget
({
double
buttonHeight
})
{
return
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FlatButton
(
height:
buttonHeight
,
child:
const
Text
(
'button'
),
onPressed:
()
{
/*ununsed*/
},
),
),
);
}
final
Finder
rawMaterialButtonFinder
=
find
.
byType
(
RawMaterialButton
);
// If height is not provided we expect the default height to be used.
await
buildWidget
();
expect
(
tester
.
widget
<
RawMaterialButton
>(
rawMaterialButtonFinder
).
constraints
.
minHeight
,
buttonDefaultMinHeight
);
// When the height is provided we expect that is used by the internal widget.
await
buildWidget
(
buttonHeight:
buttonHeight
);
expect
(
tester
.
widget
<
RawMaterialButton
>(
rawMaterialButtonFinder
).
constraints
.
minHeight
,
buttonHeight
);
});
testWidgets
(
'FlatButton minWidth parameter is used when provided'
,
(
WidgetTester
tester
)
async
{
const
double
buttonMinWidth
=
100
;
const
double
buttonDefaultMinWidth
=
88.0
;
Future
<
void
>
buildWidget
({
double
buttonMinWidth
})
{
return
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FlatButton
(
minWidth:
buttonMinWidth
,
child:
const
Text
(
'button'
),
onPressed:
()
{
/*ununsed*/
},
),
),
);
}
final
Finder
rawMaterialButtonFinder
=
find
.
byType
(
RawMaterialButton
);
// If minWidth is not provided we expect the default minWidth to be used.
await
buildWidget
();
expect
(
tester
.
widget
<
RawMaterialButton
>(
rawMaterialButtonFinder
).
constraints
.
minWidth
,
buttonDefaultMinWidth
);
// When minWidth is provided we expect that the internal widget uses it.
await
buildWidget
(
buttonMinWidth:
buttonMinWidth
);
expect
(
tester
.
widget
<
RawMaterialButton
>(
rawMaterialButtonFinder
).
constraints
.
minWidth
,
buttonMinWidth
);
});
}
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