如何在 textfieldform 小部件中添加字母间距,就像在 Text 小部件中一样,有一个字母间距选项。
Sar*_*gar 16
如果您想要普通文本中的字母间距,请使用样式属性,如下所示:
TextFormField(
style: TextStyle(
letterSpacing: 2.0,
),
),
Run Code Online (Sandbox Code Playgroud)
如果要在标签文本中使用字母间距,请在输入修饰中使用 labelstyle 属性,如下所示
TextFormField(
decoration: InputDecoration(
labelText: 'Test',
labelStyle: TextStyle(
letterSpacing: 2.0,
),
),
),
Run Code Online (Sandbox Code Playgroud)
以同样的方式,您也可以使用提示样式属性设置提示文本的样式。
使用TextStyle小部件:
TextFormField(
style : TextStyle(letterSpacing : 2.0),
// The validator receives the text that the user has entered.
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5794 次 |
| 最近记录: |