当TextFormField不活动时,无法更改默认边框颜色。当TextFormField不处于活动状态时,它将显示DarkGrey-Border颜色。因此,如何更改它。
Theme(
data: new ThemeData(
primaryColor: Colors.red,
primaryColorDark: Colors.black,
),
child: TextFormField(
decoration: new InputDecoration(
labelText: "Enter Email",
fillColor: Colors.white,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
validator: (val) {
if (val.length == 0) {
return "Email cannot be empty";
} else {
return null;
}
},
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
fontFamily: "Poppins",
),
),
),
答案 0 :(得分:1)
使用enabledBorder
中的InputDecoration
,不要忘记也可以使用focusedBorder
,如下所示:
InputDecoration(
labelText: "Enter Email",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(
color: Colors.blue,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(
color: Colors.red,
width: 2.0,
),
),
)
您在这里有更多信息:https://api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html