petras J
petras J

Reputation: 2744

Flutter TextField hintText align

How does one align hintText to the top in a TextField?

TextField (
    decoration: InputDecoration(
        hintText: 'align me to the top',
    ),
),
  1. textAlign is not affecting hintText at all.
  2. TextStyle does not have Align property as hintStyle can be used.

Upvotes: 1

Views: 4624

Answers (3)

Hekmat
Hekmat

Reputation: 531

Use textAlign property:

      textAlign: TextAlign.right,

Upvotes: 1

Lutfor Rahman
Lutfor Rahman

Reputation: 95

TextField (
textAlign: TextAlign.center,
    decoration: InputDecoration(
        hintText: 'align me to the top',
    ),
),

Upvotes: 0

rmtmckenzie
rmtmckenzie

Reputation: 40513

You may have to update with an image of what you want if this doesn't do it, but I think that it might be as simple as using labelText rather than hintText.

This is the position of the the various text you can add:

Label, hint, and helper for InputDecoration

This is what label looks like when there's no hint, the input isn't selected, and there's no text:

Label not selected

And this is what Label looks like when there's text or it's selected.

Label text example

Upvotes: 1

Related Questions