【问题标题】:Flutter - how to change TextField border color?Flutter - 如何更改 TextField 边框颜色?
【发布时间】:2019-11-23 16:22:55
【问题描述】:

我已经尽一切努力尝试更改文本字段的边框颜色,但它似乎被忽略了。

我尝试过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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 谢谢,你帮了大忙!!
    猜你喜欢
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    • 2019-12-23
    • 2021-12-07
    • 2019-03-25
    • 2018-10-11
    • 1970-01-01
    • 2019-05-09
    相关资源
    最近更新 更多