简体   繁体   English

在FLUTTER中更改TextFormField的默认边框颜色

[英]Change the default border color of TextFormField in FLUTTER

Unable to change the default border color when TextFormField is not active. 当TextFormField处于非活动状态时,无法更改默认边框颜色。 When TextFormField is not active this shows DarkGrey-Border color. 当TextFormField不处于活动状态时,它将显示DarkGrey-Border颜色。 So, how to change that. 所以,如何改变它。

在此处输入图片说明

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",
                ),
              ),
            ),

Use enabledBorder of the InputDecoration , don't forget you can also use the focusedBorder , like this : 使用enabledBorderInputDecoration ,不要忘了您也可以使用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,
                  ),
                ),
)

Here you have more info: https://api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html 在这里,您可以获得更多信息: https : //api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM