[英]How to remove background color of TextField on Flutter Widget?
您应该将填充设置为 true。
TextField(decoration: InputDecoration( fillColor: Colors.red, filled: true)),
将您的TextFormField
包裹在Container
并更改其color
属性以匹配您的背景颜色(从您的图片中我会假设它是white
):
Container(
color: Colors.white, // or any color that matches your background
child: TextFormField(
decoration: InputDecoration.collapsed(),
validator: (input) => input == "" ? 'The task is empty' : null,
onSaved: (input) => task = input,
)
),
您可以通过将TextField
包装在Theme
小部件中并将splashColor
设置为透明来使其透明
Theme(
data: Theme.of(context).copyWith(splashColor: Colors.transparent),
child: TextField(
autofocus: false,
style: TextStyle(fontSize: 22.0, color: Color(0xFFbdc6cf)),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Search',
),
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.