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
bf41c839
Unverified
Commit
bf41c839
authored
Apr 07, 2021
by
Hans Muller
Committed by
GitHub
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redo fix for button.icon layout overflow (#79085)
parent
a6153c52
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
177 additions
and
3 deletions
+177
-3
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+1
-1
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+1
-1
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+1
-1
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+58
-0
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+58
-0
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+58
-0
No files found.
packages/flutter/lib/src/material/elevated_button.dart
View file @
bf41c839
...
...
@@ -467,7 +467,7 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
final
double
gap
=
scale
<=
1
?
8
:
lerpDouble
(
8
,
4
,
math
.
min
(
scale
-
1
,
1
))!;
return
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
label
],
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
Flexible
(
child:
label
)
],
);
}
}
packages/flutter/lib/src/material/outlined_button.dart
View file @
bf41c839
...
...
@@ -373,7 +373,7 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
final
double
gap
=
scale
<=
1
?
8
:
lerpDouble
(
8
,
4
,
math
.
min
(
scale
-
1
,
1
))!;
return
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
label
],
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
Flexible
(
child:
label
)
],
);
}
}
packages/flutter/lib/src/material/text_button.dart
View file @
bf41c839
...
...
@@ -464,7 +464,7 @@ class _TextButtonWithIconChild extends StatelessWidget {
final
double
gap
=
scale
<=
1
?
8
:
lerpDouble
(
8
,
4
,
math
.
min
(
scale
-
1
,
1
))!;
return
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
label
],
children:
<
Widget
>[
icon
,
SizedBox
(
width:
gap
),
Flexible
(
child:
label
)
],
);
}
}
packages/flutter/test/material/elevated_button_test.dart
View file @
bf41c839
...
...
@@ -1114,6 +1114,64 @@ void main() {
await
tester
.
pumpAndSettle
();
}
});
testWidgets
(
'ElevatedButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
ElevatedButton
.
icon
(
onPressed:
()
{},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
// Much wider than 200
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a euismod nibh. Morbi laoreet purus.'
,
),
),
),
),
),
);
expect
(
tester
.
takeException
(),
null
);
});
testWidgets
(
'ElevatedButton.icon icon,label layout'
,
(
WidgetTester
tester
)
async
{
final
Key
buttonKey
=
UniqueKey
();
final
Key
iconKey
=
UniqueKey
();
final
Key
labelKey
=
UniqueKey
();
final
ButtonStyle
style
=
ElevatedButton
.
styleFrom
(
padding:
EdgeInsets
.
zero
,
visualDensity:
const
VisualDensity
(),
// dx=0, dy=0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
ElevatedButton
.
icon
(
key:
buttonKey
,
style:
style
,
onPressed:
()
{},
icon:
SizedBox
(
key:
iconKey
,
width:
50
,
height:
100
),
label:
SizedBox
(
key:
labelKey
,
width:
50
,
height:
100
),
),
),
),
),
);
// The button's label and icon are separated by a gap of 8:
// 46 [icon 50] 8 [label 50] 46
// The overall button width is 200. So:
// icon.x = 46
// label.x = 46 + 50 + 8 = 104
expect
(
tester
.
getRect
(
find
.
byKey
(
buttonKey
)),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
iconKey
)),
const
Rect
.
fromLTRB
(
46.0
,
0.0
,
96.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
labelKey
)),
const
Rect
.
fromLTRB
(
104.0
,
0.0
,
154.0
,
100.0
));
});
}
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
bf41c839
...
...
@@ -1290,6 +1290,64 @@ void main() {
await
tester
.
pumpAndSettle
();
}
});
testWidgets
(
'OultinedButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
OutlinedButton
.
icon
(
onPressed:
()
{},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
// Much wider than 200
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a euismod nibh. Morbi laoreet purus.'
,
),
),
),
),
),
);
expect
(
tester
.
takeException
(),
null
);
});
testWidgets
(
'OultinedButton.icon icon,label layout'
,
(
WidgetTester
tester
)
async
{
final
Key
buttonKey
=
UniqueKey
();
final
Key
iconKey
=
UniqueKey
();
final
Key
labelKey
=
UniqueKey
();
final
ButtonStyle
style
=
OutlinedButton
.
styleFrom
(
padding:
EdgeInsets
.
zero
,
visualDensity:
const
VisualDensity
(),
// dx=0, dy=0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
OutlinedButton
.
icon
(
key:
buttonKey
,
style:
style
,
onPressed:
()
{},
icon:
SizedBox
(
key:
iconKey
,
width:
50
,
height:
100
),
label:
SizedBox
(
key:
labelKey
,
width:
50
,
height:
100
),
),
),
),
),
);
// The button's label and icon are separated by a gap of 8:
// 46 [icon 50] 8 [label 50] 46
// The overall button width is 200. So:
// icon.x = 46
// label.x = 46 + 50 + 8 = 104
expect
(
tester
.
getRect
(
find
.
byKey
(
buttonKey
)),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
iconKey
)),
const
Rect
.
fromLTRB
(
46.0
,
0.0
,
96.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
labelKey
)),
const
Rect
.
fromLTRB
(
104.0
,
0.0
,
154.0
,
100.0
));
});
}
PhysicalModelLayer
_findPhysicalLayer
(
Element
element
)
{
...
...
packages/flutter/test/material/text_button_test.dart
View file @
bf41c839
...
...
@@ -1087,6 +1087,64 @@ void main() {
await
tester
.
pumpAndSettle
();
}
});
testWidgets
(
'TextButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
TextButton
.
icon
(
onPressed:
()
{},
icon:
const
Icon
(
Icons
.
add
),
label:
const
Text
(
// Much wider than 200
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a euismod nibh. Morbi laoreet purus.'
,
),
),
),
),
),
);
expect
(
tester
.
takeException
(),
null
);
});
testWidgets
(
'TextButton.icon icon,label layout'
,
(
WidgetTester
tester
)
async
{
final
Key
buttonKey
=
UniqueKey
();
final
Key
iconKey
=
UniqueKey
();
final
Key
labelKey
=
UniqueKey
();
final
ButtonStyle
style
=
TextButton
.
styleFrom
(
padding:
EdgeInsets
.
zero
,
visualDensity:
const
VisualDensity
(),
// dx=0, dy=0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SizedBox
(
width:
200
,
child:
TextButton
.
icon
(
key:
buttonKey
,
style:
style
,
onPressed:
()
{},
icon:
SizedBox
(
key:
iconKey
,
width:
50
,
height:
100
),
label:
SizedBox
(
key:
labelKey
,
width:
50
,
height:
100
),
),
),
),
),
);
// The button's label and icon are separated by a gap of 8:
// 46 [icon 50] 8 [label 50] 46
// The overall button width is 200. So:
// icon.x = 46
// label.x = 46 + 50 + 8 = 104
expect
(
tester
.
getRect
(
find
.
byKey
(
buttonKey
)),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
iconKey
)),
const
Rect
.
fromLTRB
(
46.0
,
0.0
,
96.0
,
100.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
labelKey
)),
const
Rect
.
fromLTRB
(
104.0
,
0.0
,
154.0
,
100.0
));
});
}
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