I have a TextField like this:
I want the hint and the text to be aligned at the top, not in the center.
I tried textAlign: TextAlign.start
but that is just for the horizontal alignment.
TextField(
textAlign: TextAlign.start,
expands: true,
maxLines: null,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(3),
),
hintText: 'Enter Unicode text'),
),
How to I make the text go to the top?
I found the answer so I am adding this as a self-answer Q&A.
To align the text inside of a TextField to the top, use
textAlignVertical: TextAlignVertical.top
This will give you what you want:
TextField(
textAlignVertical: TextAlignVertical.top,
expands: true,
maxLines: null,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(3),
),
hintText: 'Enter Unicode text'),
)
Add alignLabelWithHint: true,
TextFormField(
maxLines: 10,
minLines: 5,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(3),
),
hintText: 'Enter Unicode text'),
alignLabelWithHint: true,
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With