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.
This commit is contained in:
Bruno Leroux 2024-04-26 20:25:17 +02:00 committed by GitHub
parent d274a2126f
commit de411a5976
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 4 deletions

View File

@ -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.

View File

@ -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', () {