mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
d274a2126f
commit
de411a5976
@ -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.
|
||||
|
||||
@ -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', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user