I am new to Flutter Development & tried certain work around but nothing really helped. I want my text to be center vertically in TextFormField
in flutter.
textAlign: TextAlign.start
brings my text to left but I want them to be center vertically also.
textAlign: TextAlign.center
brings my text to center but I want them to be start from left also.
This is what I am getting,
This is what I want,
Snippet of my code:
@override
Widget build(BuildContext context) {
return new Form(
key: _formKey,
child: new SingleChildScrollView(
child: new Theme(
data: new ThemeData(
primaryColor: const Color(0xFF102739),
accentColor: const Color(0xFF102739),
hintColor: const Color(0xFF102739)),
child: new Column(
children: <Widget>[
new TextFormField(
textAlign: TextAlign.center,
maxLines: 1,
autofocus: true,
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
color: const Color(0xFF0f2638),
fontFamily: 'ProximaNova',
fontStyle: FontStyle.italic,
fontSize: 16.0),
decoration: new InputDecoration(
contentPadding: const EdgeInsets.only(
top: 8.0, bottom: 8.0, left: 10.0, right: 10.0),
hintText: "YOUR E-MAIL",
hintStyle: new TextStyle(
color: const Color(0x703D444E),
fontFamily: 'ProximaNova',
fontStyle: FontStyle.italic,
fontSize: 16.0),
border: new UnderlineInputBorder(
borderSide: new BorderSide(
color: const Color(0xFF0f2638), width: 0.2))),
validator: _validateEmail,
),
],
),
)));
}
to set center text vertically and horizontally in Flutter Just Use Center() widget. It will set Text to horizontally and vertically Center. The text widget has textAlign property you can give them start, end, center, justify, left, right. We can use Align Widget to set text in center align has alignment property.
Right-click the text box for which you want to set vertical alignment. On the shortcut menu, click Format Text Box. In the Format Text Box dialog box, click the Text Box tab. In the Vertical alignment box, select Top, Middle, or Bottom.
TextFormField(
textAlign: TextAlign.center,
)
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