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.
diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart
index 988eecd..f50f579 100644
--- a/packages/flutter/lib/src/material/input_decorator.dart
+++ b/packages/flutter/lib/src/material/input_decorator.dart
@@ -2783,8 +2783,7 @@
/// 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 @@
/// 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 5e3dec4..4efdd2a 100644
--- a/packages/flutter/test/material/input_decorator_test.dart
+++ b/packages/flutter/test/material/input_decorator_test.dart
@@ -3906,6 +3906,23 @@
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 @@
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', () {