Unverified Commit 5ea987db authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Adjust floating label height when font size is larrrrgeee (#21248)

parent e9e2ca16
...@@ -1835,7 +1835,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -1835,7 +1835,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
contentPadding = decorationContentPadding ?? EdgeInsets.zero; contentPadding = decorationContentPadding ?? EdgeInsets.zero;
} else if (!border.isOutline) { } else if (!border.isOutline) {
// 4.0: the vertical gap between the inline elements and the floating label. // 4.0: the vertical gap between the inline elements and the floating label.
floatingLabelHeight = 4.0 + 0.75 * inlineLabelStyle.fontSize; floatingLabelHeight = (4.0 + 0.75 * inlineLabelStyle.fontSize) * MediaQuery.textScaleFactorOf(context);
if (decoration.filled == true) { // filled == null same as filled == false if (decoration.filled == true) { // filled == null same as filled == false
contentPadding = decorationContentPadding ?? (decorationIsDense contentPadding = decorationContentPadding ?? (decorationIsDense
? const EdgeInsets.fromLTRB(12.0, 8.0, 12.0, 8.0) ? const EdgeInsets.fromLTRB(12.0, 8.0, 12.0, 8.0)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'dart:ui' as ui show window;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -2942,4 +2943,30 @@ void main() { ...@@ -2942,4 +2943,30 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('floating label does not overlap with value at large textScaleFactors', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'Just some text');
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: DefaultTextStyle(
style: const TextStyle(fontSize: 12.0, fontFamily: 'Ahem'),
child: MediaQuery(
data: MediaQueryData.fromWindow(ui.window).copyWith(textScaleFactor: 4.0),
child: Center(
child: TextField(
decoration: const InputDecoration(labelText: 'Label', border: UnderlineInputBorder()),
controller: controller,
),
),
),
),
),
),
);
await tester.tap(find.byType(TextField));
final Rect labelRect = tester.getRect(find.text('Label'));
final Rect fieldRect = tester.getRect(find.text('Just some text'));
expect(labelRect.bottom, lessThanOrEqualTo(fieldRect.top));
});
} }
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