[英]How to change the input text color to white from black in flutter textformfield
My app background color is black.我的应用程序背景颜色是黑色。 So the input text color is not visible.
所以输入文本颜色是不可见的。 So that I need to change the input text color from black to white.
所以我需要将输入文本颜色从黑色更改为白色。
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(),
),
);
}
Use the TextStyle property of TextFormField使用 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 has a style
property which you can use. TextFormField 有一个你可以使用的
style
属性。
TextFormField(
...
style: TextStyle(color: Colors.white),
)
To convert the TextField's color, you can surround it with a Theme or modify the MaterialApp theme as well.要转换 TextField 的颜色,您可以用 Theme 将其包围或修改 MaterialApp 主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.