From de411a5976fb2e49c48ee8c181fa14fcd411bcee Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Fri, 26 Apr 2024 20:25:17 +0200 Subject: [PATCH] Fix helperMaxLines and errorMaxLines documentation (#147409) ## Description This PR updates InputDecoration.helperMaxLines and InputDecoration.errorMaxLines comments. Those comments have not been updated since they landed in https://github.com/flutter/flutter/pull/17292, at that time they were probably correct but unfortunately there were no tests to catch the change of behavior. This PR adds those two missing tests. ## Tests Adds 2 tests. --- .../lib/src/material/input_decorator.dart | 6 ++-- .../test/material/input_decorator_test.dart | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 988eecd26ba..f50f5798337 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -2783,8 +2783,7 @@ class InputDecoration { /// The maximum number of lines the [helperText] can occupy. /// - /// Defaults to null, which means that the [helperText] will be limited - /// to a single line with [TextOverflow.ellipsis]. + /// Defaults to null, which means that the [helperText] is not limited. /// /// This value is passed along to the [Text.maxLines] attribute /// of the [Text] widget used to display the helper. @@ -2873,8 +2872,7 @@ class InputDecoration { /// The maximum number of lines the [errorText] can occupy. /// - /// Defaults to null, which means that the [errorText] will be limited - /// to a single line with [TextOverflow.ellipsis]. + /// Defaults to null, which means that the [errorText] is not limited. /// /// This value is passed along to the [Text.maxLines] attribute /// of the [Text] widget used to display the error. diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 5e3dec436a9..4efdd2a05b1 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -3906,6 +3906,23 @@ void main() { expect(getDecoratorRect(tester).height, closeTo(containerHeight + helperGap + errorHeight * numberOfLines, 0.25)); }); + testWidgets('Error height is not limited by default', (WidgetTester tester) async { + const int numberOfLines = 3; + await tester.pumpWidget( + buildInputDecorator( + decoration: const InputDecoration( + labelText: 'label', + errorText: threeLines, + filled: true, + ), + ), + ); + + final Rect errorRect = tester.getRect(find.text(threeLines)); + expect(errorRect.height, closeTo(errorHeight * numberOfLines, 0.25)); + expect(getDecoratorRect(tester).height, closeTo(containerHeight + helperGap + errorHeight * numberOfLines, 0.25)); + }); + testWidgets('Helper height grows to accommodate helper text', (WidgetTester tester) async { const int maxLines = 3; await tester.pumpWidget( @@ -3960,6 +3977,23 @@ void main() { expect(helperRect.height, closeTo(helperHeight * numberOfLines, 0.25)); expect(getDecoratorRect(tester).height, closeTo(containerHeight + helperGap + helperHeight * numberOfLines, 0.25)); }); + + testWidgets('Helper height is not limited by default', (WidgetTester tester) async { + const int numberOfLines = 3; + await tester.pumpWidget( + buildInputDecorator( + decoration: const InputDecoration( + labelText: 'label', + helperText: threeLines, + filled: true, + ), + ), + ); + + final Rect helperRect = tester.getRect(find.text(threeLines)); + expect(helperRect.height, closeTo(helperHeight * numberOfLines, 0.25)); + expect(getDecoratorRect(tester).height, closeTo(containerHeight + helperGap + helperHeight * numberOfLines, 0.25)); + }); }); group('Helper widget', () {