[英]Flutter change textfield underline Color
I am trying to change the underline color of a textfield when it's inactive/not focused.当文本字段处于非活动状态/未聚焦时,我试图更改它的下划线颜色。 I am not sure where to make this change,
InputDecorationTheme
is only changing the underline color for when it's selected.我不确定在哪里进行此更改,
InputDecorationTheme
仅在选择时更改下划线颜色。 How do I achieve this?我如何实现这一目标?
inputDecorationTheme: new InputDecorationTheme(
labelStyle: new TextStyle(
color: Colors.blue[200],
),
hintStyle: new TextStyle(color: Colors.grey),
),
I am trying to change this color the textfield to a lighter grey when it's not selected/out of focus.当文本字段未被选中/失焦时,我试图将文本字段的这种颜色更改为较浅的灰色。
For those who might need to achieve something similar, change the hintColor
in your Theme
widget.对于那些可能需要实现类似目标的人,请更改
Theme
小部件中的hintColor
。
new Theme(
data: new ThemeData(
//this changes the colour
hintColor: Colors.grey,
inputDecorationTheme: new InputDecorationTheme(
labelStyle: new TextStyle(color: Colors.blue))));
We can use InputDecoration
我们可以使用
InputDecoration
Try this way试试这个方法
new TextFormField(
controller: passTextController,
decoration: new InputDecoration(
labelText: "Enter password",
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
// when the TextFormField in unfocused
) ,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
// when the TextFormField in focused
) ,
border: UnderlineInputBorder(
)
),
keyboardType: TextInputType.text,
obscureText: true,
),
OUTPUT输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.