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

Conversation

zeqinjie
Copy link
Contributor

This PR changes the Hint uses topLeft alignment when maintainHintSize is false

code

buildTextField() {
  return const Center(
    child: TextField(
      decoration: InputDecoration(
        hintText: 'hint',
        maintainHintSize: false,
      ),
    ),
  );
}

Before:

b

After:
a

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 12, 2025
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Thanks for fixing, I agree this is a problem. Is there an issue about this that you know of?

Heads up that you have an analyzer failure.


final Stack stack = tester.widget<Stack>(stackFinder);
expect(stack.alignment, Alignment.topLeft);
});
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

@@ -2289,6 +2289,13 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
return FadeTransition(opacity: _curvedAnimation!, child: child);
}

static Widget _topLeftLayout(Widget? currentChild, List<Widget> previousChildren) {
return Stack(
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using an Align widget?

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

What about using an Align widget?

@justinmc Thank you for your suggestion, but layoutBuilder needs to return multiple children. It seems that this cannot be done if Align is used? The defaultLayoutBuilder implementation uses Stack to center the layout.

zeqinjie and others added 3 commits May 19, 2025 10:28
* master: (125 commits)
  Roll Fuchsia Linux SDK from XtPp9bBW49iDJ0wbA... to -eo2JqnJBauuGSzoW... (flutter#169424)
  Roll Skia from 91dc88dc70e5 to 443f5257f382 (1 revision) (flutter#169422)
  Roll Skia from 0834eea9de33 to 91dc88dc70e5 (1 revision) (flutter#169414)
  Roll Dart SDK from 0a6b16a55b9e to 7dab9bffe1f7 (1 revision) (flutter#169406)
  Correct calculation for CupertinoTextSelectionToolbar vertical position (flutter#169308)
  Baseline-align CupertinoTextField placeholder (flutter#166952)
  Roll Dart SDK from 8354914ef97b to 0a6b16a55b9e (3 revisions) (flutter#169403)
  Start removing Observatory support and references (flutter#169216)
  Roll Skia from f42bb59753fe to 0834eea9de33 (3 revisions) (flutter#169393)
  Roll Skia from 956fd8b14e22 to f42bb59753fe (2 revisions) (flutter#169379)
  [Engine] Fast blurring algorithm for RSuperellipse (flutter#169187)
  Add a page describing best CI practices for `flutter`-org repos (flutter#169364)
  Revert "Mark web_tool_tests_1_2 as bringup." (flutter#169361)
  Add changelog section for 3.32.0 and 3.32.1, and add note for ndk checking cherry pick (flutter#169369)
  Roll Dart SDK from 085f110ecf33 to 8354914ef97b (1 revision) (flutter#169349)
  Remove handling of the legacy `.flutter-plugins` file in `PluginHandler.kt`. (flutter#169317)
  Use baseUri of WebAssetServer for reload_scripts.json (flutter#169267)
  Reverts "Use pub workspace (flutter#168662)" (flutter#169357)
  Use pub workspace (flutter#168662)
  Reverts "[Reland2] Implements UISceneDelegate dynamically w/ FlutterLaunchEngine (flutter#169276)" (flutter#169347)
  ...
@dkwingsmt
Copy link
Contributor

@justinmc Can you take a look? The contributor answered your comments. (from triage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants