如何在颤动文本格式字段中将输入文本的颜色从黑色更改为白色

问题描述 投票:0回答:2

我的应用程序背景颜色为黑色,因此输入文本颜色不可见,因此我需要将输入文本颜色从黑色更改为白色

Widget showPasswordInput() {
    return Padding(
      padding: const EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0),
      child: new TextFormField(
        maxLines: 1,
        cursorColor: Colors.white,
        obscureText: true,
        autofocus: false,
        decoration: new InputDecoration(
          labelStyle: TextStyle(color: Colors.white),
            hintText: 'Password',
            hintStyle: TextStyle(color:Colors.white),
            icon: new Icon(
              Icons.lock,
              color: Colors.white,
            )),
        validator: (value) => value.isEmpty ? 'Password can\'t be empty' : null,
        onSaved: (value) => _password = value.trim(),
      ),
    );   
} 
flutter flutter-layout flutter-animation
2个回答
0
投票
使用TextFormField的TextStyle属性

Widget showPasswordInput() { return Padding( padding: const EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0), child: new TextFormField( style: TextStyle(color: Colors.white), maxLines: 1, cursorColor: Colors.white, obscureText: true, autofocus: false, decoration: new InputDecoration( labelStyle: TextStyle(color: Colors.white), hintText: 'Password', hintStyle: TextStyle(color:Colors.white), icon: new Icon( Icons.lock, color: Colors.white, )), validator: (value) => value.isEmpty ? 'Password can\'t be empty' : null, onSaved: (value) => _password = value.trim(), ), ); }


0
投票
TextFormField具有可以使用的style属性。

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

要转换TextField的颜色,您可以在主题周围加上它或修改MaterialApp主题。
© www.soinside.com 2019 - 2024. All rights reserved.