Flutter-如何更改TextField边框颜色?

时间:2019-07-14 22:49:51

标签: android-studio flutter dart uitextfield flutter-layout

我已经尝试了所有尝试来更改文本字段的边框颜色,但是它似乎被忽略了。

我尝试了sideBorder(即使宽度也被忽略),hintStyle,仅将特定主题应用于此小部件,它们似乎都被忽略了。

child: new Theme(
      data: ThemeData(
      primaryColor: Colors.white,
      accentColor: Colors.white,
      hintColor: Colors.white //This is Ignored,
      inputDecorationTheme: InputDecorationTheme(
               border: OutlineInputBorder(
               borderSide: BorderSide(color: Colors.white) //This is Ignored
                    ),
                  ),
              ),
      child: new TextField(
             style: TextStyle(color: Colors.white, decorationColor: Colors.white),
             cursorColor: Colors.white,
             decoration: InputDecoration(
             border: new OutlineInputBorder(
             //borderRadius: const BorderRadius.all(Radius.circular(30.0)),
             borderSide: BorderSide(color: Colors.white, width: 0.0) //This is Ignored,
                      ),
                      hintText: "Search people",
                    ),
                  ),
                  //new Divider(color: Colors.white, height: 20),

          )

我想将发际线更改为黑色边框,并更改其颜色和宽度。

Image of what it currently is

1 个答案:

答案 0 :(得分:0)

使用enabledBorderfocusedBorder(当文本框成为焦点时)

InputDecoration(
              enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                      color: Colors.red, width: 5.0),
                  ),
              focusedBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                      color: Colors.blue, width: 3.0),
                  ),
              hintText: "Search people",
            ),