首页 > 解决方案 > 如何更改 TextField 中字符串输入的颜色?

问题描述

我正在使用我的应用程序的样式,我无法更改输入的颜色,TextField没有任何属性可以更改它。

 Theme(
            data: new ThemeData(
              hintColor: Colors.white
            ),
            child:
        TextField(
          focusNode: _focusUsername,
          controller: _controller,
          decoration: InputDecoration(
            border: InputBorder.none,
            fillColor: Colors.grey,
            filled: true,
            hintText: 'Username',
          ))),

标签: flutterdart

解决方案


您可以分配一个TextStyle

TextField(
  style: TextStyle(color: Colors.white),
  ...
)

https://docs.flutter.io/flutter/painting/TextStyle-class.html


推荐阅读