我正在try 使用BorderSide更改TextField的边框 colored颜色 ,但不起作用.

这是我下面的代码.

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

结果的屏幕截图如下所示.

推荐答案

这不会因为设置到屏幕上的默认主题而改变.

因此,只需将TextField包装为new ThemeData(),即可为您正在绘制的小部件更改它们

child: new Theme(
          data: new ThemeData(
            primaryColor: Colors.redAccent,
            primaryColorDark: Colors.red,
          ),
          child: 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)),
          ),
        ));

enter image description here

Flutter相关问答推荐

使用Flutter,使用Photoshop下载的二进制文件(wav)发生意外转换

创建多个具有适当填充和对齐的按钮的最佳方法

Flutter ReorderableListView在可滚动父级中无法完美工作

从底部开始固定,然后使其可拖曳Flutter

如何正确处理Flutter 翼中使用火基时发生的碰撞?

在VSCode中运行应用程序而不进行调试时,控制台仍显示为调试模式

如何在Flutter Webview包中触发基于URL导航的事件

如何处理平台游戏的对象冲突?

请求已在 flutter 中发送到 django 服务器,并且已返回响应,但条件仍然为 false

如何将取消图标放置在右上角

为什么我们需要使用ChangeNotifierProvider而不是仅仅使用ChangeNotifier?

Flutter - 我需要显示文本,但应用程序不需要

flutter 在文本字段中更改部分文本选定 colored颜色

如何在图像上点或(图像的一部分)在 flutter 中点击?

我怎样才能一次只选中一个复选框?

在 Flutter 中更改高架按钮 OnPressed 的背景 colored颜色

如何获取 android 和 Ios (flutter) 的 CircularProgress 指示器?

如何使用 Riverpod 在运行时动态创建提供程序?

阴影效果只出现在一张卡片的左边 在Flutter 中?

带有 Dismissible 和 Provider (NotifyListener) 的笨拙动画