diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index cd3875bdb6..9bc4cc6e6b 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -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, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 056e8b6f72..35a86461fa 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -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();