dart - 如何在 Flutter 中更改 TextFormField 输入文本颜色

在 uni 为 Flutter 应用程序做 UI,我只希望在 TextFormField 中输入的文本是白色的。这似乎是不必要的困难。我试过谷歌搜索等,但看不到明显的答案。

  new Theme(
    // this colors the underline
    data: theme.copyWith(
      primaryColor: Colors.white,
      hintColor: Colors.transparent,

    ),
    child: new Padding(
      padding: const EdgeInsets.fromLTRB(32.0, 40.0, 32.0, 4.0),
      child: TextFormField(

          key: Key('username'),
          keyboardType: TextInputType.text,
          controller: usernameController,
          decoration: InputDecoration(

              fillColor: Colors.black.withOpacity(0.6),
              filled: true,
              border: new OutlineInputBorder(

                borderRadius: const BorderRadius.all(

                  const Radius.circular(8.0),
                ),
                borderSide: new BorderSide(
                  color: Colors.transparent,
                  width: 1.0,
                ),
              ),
              labelText: 'Username',
              labelStyle:
                  new TextStyle(color: Colors.white, fontSize: 16.0)),
          style:
              TextStyle(fontSize: 20.0, color: textTheme.button.color),
          validator: validateUserName,
          onSaved: (val) => this.loginFields._username = val),
    ),
  ),

最佳答案

这样就可以了:

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

https://stackoverflow.com/questions/52603494/

相关文章:

database - 任何用于 Flutter 的持久性 NoSQL 数据存储?

flutter - Flutter中如何改变ListView的overscroll发光效果颜色?

facebook - 如何在 Flutter 应用中实现分享按钮?

firebase - 使用 Flutter 向 Cloud Firestore 添加对象

dart - Flutter 中带有调整下拉箭头图标的全宽 DropdownButton

dart - Flutter 自定义动画对话框

datetime - 如何到达 Dart 的最后一个午夜?

flutter - 如何使用flutter存储登录信息?

dart - Flutter - 我正在寻找一种制作脉冲动画的方法

mobile - Flutter - Sliver List 内的 Sliver Layout 水平