Flutter 如何更改文本字段中输入的字符串的颜色?

Flutter 如何更改文本字段中输入的字符串的颜色?,flutter,dart,Flutter,Dart,我正在使用我的应用程序的样式,我无法更改文本字段输入的颜色,没有任何属性可以更改它 Theme( data: new ThemeData( hintColor: Colors.white ), child: TextField( focusNode: _focusUsername, controller: _controller,

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

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

您可以指定
TextStyle

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

在下面的示例中,文本为“红色”,文本字段的背景为“橙色”

TextField(
  style: TextStyle(color: Colors.red),
  decoration: InputDecoration(fillColor: Colors.orange, filled: true),
)
这就是你的意思吗

如果你想通过应用程序的主题来实现这一点,这确实很棘手。可能是这样的:

theme: ThemeData(
    textTheme: TextTheme(
      bodyText1: TextStyle(color: Colors.black),
      bodyText2: TextStyle(color: Colors.black),
      button: TextStyle(color: Colors.black),
      caption: TextStyle(color: Colors.black),
      subtitle1: TextStyle(color: Colors.red), // <-- that's the one
      headline1: TextStyle(color: Colors.black),
      headline2: TextStyle(color: Colors.black),
      headline3: TextStyle(color: Colors.black),
      headline4: TextStyle(color: Colors.black),
      headline5: TextStyle(color: Colors.black),
      headline6: TextStyle(color: Colors.black),
    ),
    inputDecorationTheme: InputDecorationTheme(
      fillColor: Colors.orange,
      filled: true,
    )
)
主题:主题数据( textTheme:textTheme( bodyText1:TextStyle(颜色:Colors.black), bodyText2:TextStyle(颜色:Colors.black), 按钮:文本样式(颜色:Colors.black), 描述:文本样式(颜色:Colors.black),
字幕1:TextStyle(颜色:Colors.red),//要在我使用的主题数据中更改它:

ThemeData(
      textTheme: TextTheme(subtitle1: TextStyle(color: Colors.grey)),

您想更改什么颜色?文本、插入符号、背景、边框等?您尝试了什么?请将代码添加到您的问题中。我想将您编写的文本更改为白色,但我只能更改提示。
final newTextTheme=Theme.of(context.textTheme.apply)(bodyColor:Colors.white,//displayColor:Colors.pink,)
最终采用了这种方式。令人惊讶的是,您的解决方案在尝试在main方法的通用主题配置上设置颜色时仍然有效。但为什么它被称为subtitle1?@ana及其材质设计排版系统术语