flutter - 如何在 flutter 中更改 textField 的下划线颜色?

我试图定义输入装饰来改变输入文本字段下划线的颜色。但它不起作用。谁能建议我在这里缺少什么?

这是代码片段:

decoration: InputDecoration(
    hintText: 'Username',
    hintStyle: TextStyle(color: Colors.white),
    border: new UnderlineInputBorder(
                                    borderSide: BorderSide(color: Colors.white, 
                                      width: 1.0, style: BorderStyle.none ),
    ),

最佳答案

decoration: InputDecoration(
  hintText: 'Username',
  hintStyle: TextStyle(color: Colors.white),
  enabledBorder: new UnderlineInputBorder(
    borderSide: BorderSide(
      color: Colors.white, 
      width: 1.0, 
      style: BorderStyle.none 
    ),
  ),
),

只需将 border 更改为 enabledBorder。希望对您有所帮助!

https://stackoverflow.com/questions/51373884/

相关文章:

flutter - 在 Flutter 的嵌套 Navigator 结构中,如何获取特定的 Navi

dart - 如何在没有用户交互的情况下发送短信?

dart - 在 flutter 中使用其 GlobalKey 获取 Widget 的高度

dart - Flutter 嵌套小部件回调/异步问题

flutter - 在创建带有 float 应用栏的应用时使用 StreamBuilder

dart - 如何将 showModalBottomSheet 设置为全高?

flutter - 如何从 Dart 中的 future 返回错误?

multithreading - 如何在 Flutter 中在后台运行任务?

flutter - 如何知道小部件在视口(viewport)中是否可见?

flutter - 如何在 Flutter 应用中获取屏幕大小?