Unverified Commit 50a7da85 authored by YeungKC's avatar YeungKC Committed by GitHub

Fix text field label width on outline input border (#67736)

parent c0176c9e
......@@ -980,7 +980,7 @@ class _RenderDecoration extends RenderBox {
_boxSize(icon).width
+ contentPadding.left
+ _boxSize(prefixIcon).width
+ _boxSize(suffixIcon).width
+ (decoration.border!.isOutline ? 0.0 : _boxSize(suffixIcon).width)
+ contentPadding.right));
boxToBaseline[label] = _layoutLineBox(
label,
......
......@@ -4253,6 +4253,40 @@ void main() {
expect(getOpacity(tester, prefixText), 1.0);
});
testWidgets('OutlineInputBorder with InputDecorator long label, width should ignore icon width', (WidgetTester tester) async {
// Related issue: https://github.com/flutter/flutter/issues/64427
const String labelText = 'Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.';
Widget getLabeledInputDecorator(bool useOutlineBorder) => MaterialApp(
home: Material(
child: Container(
width: 300,
child: TextField(
decoration: InputDecoration(
border: useOutlineBorder ? const OutlineInputBorder(
borderSide: BorderSide(color: Colors.greenAccent, width: 1.0),
) : null,
suffixIcon: const Icon(Icons.arrow_drop_down),
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: labelText,
),
),
),
),
);
// Build with no OutlineInputBorder.
await tester.pumpWidget(getLabeledInputDecorator(false));
// Get the width of the label when there is no OutlineInputBorder.
final double labelWidth = tester.getSize(find.text(labelText)).width;
// Build with a OutlineInputBorder.
await tester.pumpWidget(getLabeledInputDecorator(true));
expect(tester.getSize(find.text(labelText)).width > labelWidth, isTrue);
});
testWidgets('given enough space, constrained and unconstrained heights result in the same size widget', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/65572
final UniqueKey keyUnconstrained = 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