Skip to content

When maintainHintSize is false, hint is centered and aligned, it is different from the original one #168654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update test
  • Loading branch information
zeqinjie committed May 19, 2025
commit c74ad6f0f74619b41f7481b335a86d854207b36b
17 changes: 14 additions & 3 deletions packages/flutter/test/material/input_decorator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5244,14 +5244,15 @@ void main() {
expect(find.text(hintText), findsNothing);
});

testWidgets('Hint uses topLeft alignment when maintainHintSize is false',
(WidgetTester tester) async {
testWidgets('Hint uses topLeft alignment when maintainHintSize is false', (
WidgetTester tester,
) async {
const InputDecoration decoration = InputDecoration(
hintText: hintText,
maintainHintSize: false,
);

await tester.pumpWidget(buildInputDecorator(decoration: decoration));
await tester.pumpWidget(buildInputDecorator(isEmpty: true, decoration: decoration));

final Finder animatedSwitcherFinder = find.byType(AnimatedSwitcher);
expect(animatedSwitcherFinder, findsOneWidget);
Expand All @@ -5264,6 +5265,16 @@ void main() {

final Stack stack = tester.widget<Stack>(stackFinder);
expect(stack.alignment, Alignment.topLeft);

final Finder hintTextFinder = find.text(hintText);
expect(hintTextFinder, findsOneWidget);

// Get the hint text box and stack box to calculate the position of the hint text.
final RenderBox hintTextBox = tester.renderObject<RenderBox>(hintTextFinder);
final RenderBox stackBox = tester.renderObject<RenderBox>(stackFinder);
final Offset hintTextPosition = hintTextBox.localToGlobal(Offset.zero, ancestor: stackBox);
expect(hintTextPosition.dx, 0.0);
expect(hintTextPosition.dy, 0.0);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check the actual left position of the hintText too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinmc Thanks you, I updated

});

Expand Down