diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 75301320c2..26cf16ff79 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -1243,11 +1243,16 @@ class _RenderDecoration extends RenderBox { double subtextHeight = _lineHeight(width, [helperError, counter]); if (subtextHeight > 0.0) subtextHeight += subtextGap; - return contentPadding.top + final Offset densityOffset = decoration.visualDensity.baseSizeAdjustment; + final double containerHeight = contentPadding.top + (label == null ? 0.0 : decoration.floatingLabelHeight) + _lineHeight(width, [prefix, input, suffix]) + subtextHeight + contentPadding.bottom; + final double minContainerHeight = decoration.isDense || expands + ? 0.0 + : kMinInteractiveDimension + densityOffset.dy; + return math.max(containerHeight, minContainerHeight); } @override diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index fdb56972a1..bcaa972f43 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -7417,6 +7417,48 @@ void main() { final RenderBox renderBox = tester.renderObject(find.byType(TextField)); expect(renderBox.size.height, lessThan(kMinInteractiveDimension)); }); + + group('intrinsics', () { + Widget _buildTest({ bool isDense }) { + return MaterialApp( + home: Scaffold( + body: CustomScrollView( + slivers: [ + SliverFillRemaining( + hasScrollBody: false, + child: Column( + children: [ + TextField( + decoration: InputDecoration( + isDense: isDense, + ) + ), + Container( + height: 1000, + ), + ], + ) + ) + ], + ) + ) + ); + } + + testWidgets('By default, intrinsic height is at least kMinInteractiveDimension high', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/54729 + // If the intrinsic height does not match that of the height after + // performLayout, this will fail. + tester.pumpWidget(_buildTest(isDense: false)); + }); + + testWidgets('When isDense, intrinsic height can go below kMinInteractiveDimension height', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/54729 + // If the intrinsic height does not match that of the height after + // performLayout, this will fail. + tester.pumpWidget(_buildTest(isDense: true)); + }); + }); }); testWidgets("Arrow keys don't move input focus", (WidgetTester tester) async { final TextEditingController controller1 = TextEditingController();