我看到了一些使用Padding的分辨率,但是我不知道这是否是最好的解决方案...还有另一种方法可以将文本置于TextFormField内部吗?
class _InputFormFieldState extends State<InputFormField> {
@override
Widget build(BuildContext context) {
return Container(
width: this.widget.width,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
boxShadow: ThemeEffect.shadowInputField()
),
child: TextFormField(
controller: this.widget.controller,
validator: this.widget.validator,
style: ThemeText.sign_up_input_field,
decoration: InputDecoration(
errorBorder:OutlineInputBorder(
borderSide: BorderSide(
color: ThemeColor.flamingo,
width: 2
),
),
errorStyle: TextStyle(height: 0),
hintText: this.widget.hintText,
hintStyle: ThemeText.sign_up_input_field_hint,
border: new OutlineInputBorder(
borderRadius: BorderRadius.circular(6.0),
borderSide: BorderSide.none,
),
filled: true,
fillColor: ThemeColor.white
),
),
);
}
}
答案 0 :(得分:1)
在您的TextFormField
中。
添加-textAlign: TextAlign.center,
...
child: TextFormField(
controller: this.widget.controller,
textAlign: TextAlign.center, // Add this Line
validator: this.widget.validator,
style: ThemeText.sign_up_input_field,
...
答案 1 :(得分:0)
尝试一下:
TextField(
textAlign: TextAlign.center,
)
答案 2 :(得分:0)
无需使用填充,因为该属性已由窗口小部件提供,因此您只需添加TextAlign.center即可解决此问题,就像这样:
TextFormField(
textAlign: TextAlign.center,