dart - 无法更改 TextField 边框颜色

标签 dart flutter

我正在尝试使用 BorderSide 更改我的 TextField 边框的颜色,但它不起作用。

这是我下面的代码。

new TextField(
  decoration: new InputDecoration(
    border: new OutlineInputBorder(
      borderSide: new BorderSide(color: Colors.teal)
    ),
    hintText: 'Tell us about yourself',
    helperText: 'Keep it short, this is just a demo.',
    labelText: 'Life story',
    prefixIcon: const Icon(Icons.person, color: Colors.green,),
    prefixText: ' ',
    suffixText: 'USD',
    suffixStyle: const TextStyle(color: Colors.green)),
  )
)

结果截图如下。

最佳答案

这样做的新方法是像这样使用 enabledBorder:

new TextField(
  decoration: new InputDecoration(
    enabledBorder: const OutlineInputBorder(
      borderSide: const BorderSide(color: Colors.grey, width: 0.0),
    ),
    focusedBorder: ...
    border: ...
  ),
)

关于dart - 无法更改 TextField 边框颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50122394/

相关文章:

dart - 如何在 Dart 中将相对路径转换为绝对路径?

flutter - 如何对flutter中的西里尔字母列表进行排序

flutter - GridView 自动将行高设置为最高的网格项

flutter - getter 'length'在null上被调用。接收方:空尝试调用:长度。相关的引起错误的小部件是:/bottom_bar.dart:17:64

dart - Flutter/Dart语言客户端证书认证

dart - 有没有办法判断当前是否正在播放声音?

dart - Flutter - 如何使用 Canvas 围绕中心旋转图像

Flutter - 如何存储字符串列表

dart - 是否有任何功能可以从DART中的给定字符串中选择随机字符

dart - flutter/dart 中的 widget.something 到底调用了什么?