我是 Flutter Development 的新手并尝试了某些解决方法,但没有任何帮助。我希望我的文本在 TextFormField
中 垂直 居中。
textAlign: TextAlign.start
将我的文字带到左边,但我希望它们也垂直居中。 textAlign: TextAlign.center
将我的文本置于中心,但我希望它们也从左侧开始。
我的代码片段:
@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,
),
],
),
)));
}
原文由 buzzingsilently 发布,翻译遵循 CC BY-SA 4.0 许可协议
没有垂直对齐选项。您需要做的就是设置
contentPadding
用于定位:截屏