[英]How to change the input text color to white from black in flutter textformfield
我的應用程序背景顏色是黑色。 所以輸入文本顏色是不可見的。 所以我需要將輸入文本顏色從黑色更改為白色。
Widget showPasswordInput() {
return Padding(
padding: const EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0),
child: new TextFormField(
maxLines: 1,
cursorColor: Colors.white,
obscureText: true,
autofocus: false,
decoration: new InputDecoration(
labelStyle: TextStyle(color: Colors.white),
hintText: 'Password',
hintStyle: TextStyle(color:Colors.white),
icon: new Icon(
Icons.lock,
color: Colors.white,
)),
validator: (value) => value.isEmpty ? 'Password can\'t be empty' : null,
onSaved: (value) => _password = value.trim(),
),
);
}
使用 TextFormField 的 TextStyle 屬性
Widget showPasswordInput() {
return Padding(
padding: const EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0),
child: new TextFormField(
style: TextStyle(color: Colors.white),
maxLines: 1,
cursorColor: Colors.white,
obscureText: true,
autofocus: false,
decoration: new InputDecoration(
labelStyle: TextStyle(color: Colors.white),
hintText: 'Password',
hintStyle: TextStyle(color:Colors.white),
icon: new Icon(
Icons.lock,
color: Colors.white,
)),
validator: (value) => value.isEmpty ? 'Password can\'t be empty' : null,
onSaved: (value) => _password = value.trim(),
),
);
}
TextFormField 有一個你可以使用的style
屬性。
TextFormField(
...
style: TextStyle(color: Colors.white),
)
要轉換 TextField 的顏色,您可以用 Theme 將其包圍或修改 MaterialApp 主題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.