![](/img/trans.png)
[英]How to change TextFormField labeltext and border color in Flutter?
[英]Change the default border color of TextFormField in FLUTTER
當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",
),
),
),
使用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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.