File tree 2 files changed +42
-1
lines changed 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -1331,8 +1331,10 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
1331
1331
// Similarly, we don't reduce the height of the button so much that its icon
1332
1332
// would be clipped.
1333
1333
double get _denseButtonHeight {
1334
+ final double textScaleFactor = MediaQuery .of (context).textScaleFactor;
1334
1335
final double fontSize = _textStyle! .fontSize ?? Theme .of (context).textTheme.subtitle1! .fontSize! ;
1335
- return math.max (fontSize, math.max (widget.iconSize, _kDenseButtonHeight));
1336
+ final double scaledFontSize = textScaleFactor * fontSize;
1337
+ return math.max (scaledFontSize, math.max (widget.iconSize, _kDenseButtonHeight));
1336
1338
}
1337
1339
1338
1340
Color get _iconColor {
Original file line number Diff line number Diff line change @@ -567,6 +567,45 @@ void main() {
567
567
}
568
568
});
569
569
570
+ testWidgets ('DropdownButtonFormField with isDense:true does not clip large scale text' ,
571
+ (WidgetTester tester) async {
572
+ final Key buttonKey = UniqueKey ();
573
+ const String value = 'two' ;
574
+
575
+ await tester.pumpWidget (
576
+ TestApp (
577
+ textDirection: TextDirection .ltr,
578
+ child: Builder (
579
+ builder: (BuildContext context) => MediaQuery (
580
+ data: MediaQuery .of (context).copyWith (textScaleFactor: 3.0 ),
581
+ child: Material (
582
+ child: Center (
583
+ child: DropdownButtonFormField <String >(
584
+ key: buttonKey,
585
+ value: value,
586
+ onChanged: onChanged,
587
+ items: menuItems.map <DropdownMenuItem <String >>((String item) {
588
+ return DropdownMenuItem <String >(
589
+ key: ValueKey <String >(item),
590
+ value: item,
591
+ child: Text (item,
592
+ key: ValueKey <String >('${item }Text' ),
593
+ style: const TextStyle (fontSize: 20.0 )),
594
+ );
595
+ }).toList (),
596
+ ),
597
+ ),
598
+ ),
599
+ ),
600
+ ),
601
+ ),
602
+ );
603
+
604
+ final RenderBox box =
605
+ tester.renderObject <RenderBox >(find.byType (dropdownButtonType));
606
+ expect (box.size.height, 72.0 );
607
+ });
608
+
570
609
testWidgets ('DropdownButtonFormField.isDense is true by default' , (WidgetTester tester) async {
571
610
// Regression test for https://github.com/flutter/flutter/issues/46844
572
611
final Key buttonKey = UniqueKey ();
You can’t perform that action at this time.
0 commit comments