如何更改TextFormField小部件的颜色Flutter

问题描述

我将原色从黑色更改为白色。 我所有的TextFormField()焦点颜色都变成了白色。 我该如何更改颜色 我试图更改颜色属性,但是根本不起作用

 TextFormField(
     style: TextStyle(color: Colors.grey),focusNode: _confirmPasswordFocusNode,obscureText: true,decoration: InputDecoration(
     fillColor: Colors.black54,hoverColor: Colors.black54,focusColor: Colors.black54,labelText: '비밀번호 확인',icon: Icon(Icons.lock_outline)),onChanged: (value) {
        ...

enter image description here

每个人有人帮助我 正文:TextFormField(),

解决方法

放置cursorColor:TextFormField内部的Colors.white

TextField(
  cursorColor: Colors.red,),

像调用MaterialApp一样设置主题属性的cursorColor

    MaterialApp(
        title: "Flutter App",theme: ThemeData(
        cursorColor: Colors.red,home: HomeScreen(),)
,

由于屏幕上设置了默认方案,因此它没有改变。

您只需通过使用新ThemeData()包装TextFormField来更改正在绘制的小部件

      Theme(
          data: new ThemeData(
            primaryColor: Colors.black54,focusColor: Colors.black54,hintColor: Colors.black54,child: TextFormField(
            style: TextStyle(color: Colors.grey),obscureText: true,decoration: InputDecoration(
                labelText: '비밀번호 확인',icon: Icon(Icons.lock_outline)),

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...