File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 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
13311331 // Similarly, we don't reduce the height of the button so much that its icon
13321332 // would be clipped.
13331333 double get _denseButtonHeight {
1334+ final double textScaleFactor = MediaQuery .of (context).textScaleFactor;
13341335 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));
13361338 }
13371339
13381340 Color get _iconColor {
Original file line number Diff line number Diff line change @@ -567,6 +567,45 @@ void main() {
567567 }
568568 });
569569
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+
570609 testWidgets ('DropdownButtonFormField.isDense is true by default' , (WidgetTester tester) async {
571610 // Regression test for https://github.com/flutter/flutter/issues/46844
572611 final Key buttonKey = UniqueKey ();
You can’t perform that action at this time.
0 commit comments