mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Adjust floating label height when font size is larrrrgeee (#21248)
This commit is contained in:
parent
e9e2ca160d
commit
5ea987db1d
@ -1835,7 +1835,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
contentPadding = decorationContentPadding ?? EdgeInsets.zero;
|
||||
} else if (!border.isOutline) {
|
||||
// 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
|
||||
contentPadding = decorationContentPadding ?? (decorationIsDense
|
||||
? const EdgeInsets.fromLTRB(12.0, 8.0, 12.0, 8.0)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:ui' as ui show window;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@ -2942,4 +2943,30 @@ void main() {
|
||||
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user