Unverified Commit 74ac8678 authored by Foong Siqi's avatar Foong Siqi Committed by GitHub

Modify calculation of dense button height when text scale is large for dropdown button (#107201)

parent 7148cba6
......@@ -1331,8 +1331,10 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
// Similarly, we don't reduce the height of the button so much that its icon
// would be clipped.
double get _denseButtonHeight {
final double textScaleFactor = MediaQuery.of(context).textScaleFactor;
final double fontSize = _textStyle!.fontSize ?? Theme.of(context).textTheme.subtitle1!.fontSize!;
return math.max(fontSize, math.max(widget.iconSize, _kDenseButtonHeight));
final double scaledFontSize = textScaleFactor * fontSize;
return math.max(scaledFontSize, math.max(widget.iconSize, _kDenseButtonHeight));
}
Color get _iconColor {
......
......@@ -567,6 +567,45 @@ void main() {
}
});
testWidgets('DropdownButtonFormField with isDense:true does not clip large scale text',
(WidgetTester tester) async {
final Key buttonKey = UniqueKey();
const String value = 'two';
await tester.pumpWidget(
TestApp(
textDirection: TextDirection.ltr,
child: Builder(
builder: (BuildContext context) => MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0),
child: Material(
child: Center(
child: DropdownButtonFormField<String>(
key: buttonKey,
value: value,
onChanged: onChanged,
items: menuItems.map<DropdownMenuItem<String>>((String item) {
return DropdownMenuItem<String>(
key: ValueKey<String>(item),
value: item,
child: Text(item,
key: ValueKey<String>('${item}Text'),
style: const TextStyle(fontSize: 20.0)),
);
}).toList(),
),
),
),
),
),
),
);
final RenderBox box =
tester.renderObject<RenderBox>(find.byType(dropdownButtonType));
expect(box.size.height, 72.0);
});
testWidgets('DropdownButtonFormField.isDense is true by default', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46844
final Key buttonKey = UniqueKey();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment