[英]Flutter: TextField Border Color Not Applied
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated
? Colors.orange
: Colors.white)),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated
? Colors.orange
: Colors.red)),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated
? Colors.orange
: Colors.red)),
I am trying to apply Red
color when password has not been typed or _isPasswordValidated
value is false.我正在尝试在未输入密码或_isPasswordValidated
值为 false 时应用Red
。 However, only orange color has been applied.但是,只应用了橙色。
Is there anyway that I can change the color without using Theme
?无论如何,我可以在不使用Theme
的情况下更改颜色吗?
On idle, you need to use enabledBorder
, also check focusedBorder
and goes on.在闲置时,您需要使用enabledBorder
,同时检查focusedBorder
并继续。
Full details on inputDecoration-class inputDecoration 类的完整详细信息
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated ? Colors.orange : Colors.white,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: Colors.pink,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated ? Colors.orange : Colors.red,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated ? Colors.orange : Colors.red,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2,
color: _isPasswordValidated ? Colors.orange : Colors.red,
),
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.