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
a0233233
Commit
a0233233
authored
Oct 11, 2018
by
Hans Muller
Committed by
matthew-carroll
Oct 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MaterialButton must honor its minWidth and height parameters (#22919)
parent
081d2a7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
material_button.dart
packages/flutter/lib/src/material/material_button.dart
+4
-1
buttons_test.dart
packages/flutter/test/material/buttons_test.dart
+68
-1
No files found.
packages/flutter/lib/src/material/material_button.dart
View file @
a0233233
...
@@ -258,7 +258,10 @@ class MaterialButton extends StatelessWidget {
...
@@ -258,7 +258,10 @@ class MaterialButton extends StatelessWidget {
elevation:
buttonTheme
.
getElevation
(
this
),
elevation:
buttonTheme
.
getElevation
(
this
),
highlightElevation:
buttonTheme
.
getHighlightElevation
(
this
),
highlightElevation:
buttonTheme
.
getHighlightElevation
(
this
),
padding:
buttonTheme
.
getPadding
(
this
),
padding:
buttonTheme
.
getPadding
(
this
),
constraints:
buttonTheme
.
constraints
,
constraints:
buttonTheme
.
getConstraints
(
this
).
copyWith
(
minWidth:
minWidth
,
minHeight:
height
,
),
shape:
buttonTheme
.
shape
,
shape:
buttonTheme
.
shape
,
clipBehavior:
clipBehavior
??
Clip
.
none
,
clipBehavior:
clipBehavior
??
Clip
.
none
,
animationDuration:
buttonTheme
.
getAnimationDuration
(
this
),
animationDuration:
buttonTheme
.
getAnimationDuration
(
this
),
...
...
packages/flutter/test/material/buttons_test.dart
View file @
a0233233
...
@@ -409,6 +409,73 @@ void main() {
...
@@ -409,6 +409,73 @@ void main() {
semantics
.
dispose
();
semantics
.
dispose
();
});
});
testWidgets
(
'MaterialButton minWidth and height parameters'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
double
minWidth
,
double
height
,
EdgeInsets
padding
=
EdgeInsets
.
zero
,
Widget
child
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
MaterialButton
(
padding:
padding
,
minWidth:
minWidth
,
height:
height
,
onPressed:
null
,
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
child:
child
,
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
minWidth:
8.0
,
height:
24.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
8.0
,
24.0
));
await
tester
.
pumpWidget
(
buildFrame
(
minWidth:
8.0
));
// Default minHeight constraint is 36, see RawMaterialButton.
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
8.0
,
36.0
));
await
tester
.
pumpWidget
(
buildFrame
(
height:
8.0
));
// Default minWidth constraint is 88, see RawMaterialButton.
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
88.0
,
8.0
));
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
88.0
,
36.0
));
await
tester
.
pumpWidget
(
buildFrame
(
padding:
const
EdgeInsets
.
all
(
4.0
)));
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
88.0
,
36.0
));
// Size is defined by the padding.
await
tester
.
pumpWidget
(
buildFrame
(
minWidth:
0.0
,
height:
0.0
,
padding:
const
EdgeInsets
.
all
(
4.0
),
),
);
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
8.0
,
8.0
));
// Size is defined by the padded child.
await
tester
.
pumpWidget
(
buildFrame
(
minWidth:
0.0
,
height:
0.0
,
padding:
const
EdgeInsets
.
all
(
4.0
),
child:
const
SizedBox
(
width:
8.0
,
height:
8.0
),
),
);
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
16.0
,
16.0
));
// Size is defined by the minWidth, height constraints.
await
tester
.
pumpWidget
(
buildFrame
(
minWidth:
18.0
,
height:
18.0
,
padding:
const
EdgeInsets
.
all
(
4.0
),
child:
const
SizedBox
(
width:
8.0
,
height:
8.0
),
),
);
expect
(
tester
.
getSize
(
find
.
byType
(
MaterialButton
)),
const
Size
(
18.0
,
18.0
));
});
testWidgets
(
'MaterialButton size is configurable by ThemeData.materialTapTargetSize'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialButton size is configurable by ThemeData.materialTapTargetSize'
,
(
WidgetTester
tester
)
async
{
final
Key
key1
=
UniqueKey
();
final
Key
key1
=
UniqueKey
();
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
...
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