微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在flutter中更改TextField的颜色样式

如何解决如何在flutter中更改TextField的颜色样式

我有一个像这样的简单 TextField 小部件

TextField(
      obscureText: widget.placeholder == "Password" ? _isHidePassword : false,decoration: Inputdecoration(
        
        hintText: "${widget.placeholder}",hintStyle: TextStyle(
          color: Colors.grey,),// labelText: "${widget.placeholder}",// labelStyle: TextStyle(color: greenMain),)

它给出了如下图所示的结果:

enter image description here

有没有办法把蓝色变成另一种颜色?喜欢红色还是绿色?

解决方法

试试吧

Theme(
        data: new ThemeData(
          primaryColor: Colors.redAccent,primaryColorDark: Colors.red,),child: TextField(
          keyboardType: TextInputType.text,decoration: InputDecoration(
            
            labelText: "Text field*",
,

您可以像这样在 TextField 上使用装饰:

decoration: InputDecoration(
hintText: 'Type Text Here',enabledBorder: UnderlineInputBorder(      
borderSide: BorderSide(color: Colors.red),

这会将线条更改为红色。

希望能帮到你

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。