gpt4 book ai didi

flutter - 如何为图标按钮设置背景颜色?

转载 作者:IT王子 更新时间:2023-10-29 06:47:41 31 4
gpt4 key购买 nike

我想为图标按钮应用背景色,但我没有看到它的显式 backgroundColor 属性。我想实现这个:

enter image description here

目前我能够实现到这里:

enter image description here

下面是目前的代码:

@override
Widget build(BuildContext context) {

return Scaffold(
resizeToAvoidBottomPadding: false,
backgroundColor: Color(0xFF13212C),
appBar: AppBar(
title: Text('Demo'),
),
drawer: appDrawer(),
body: new Center(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Column(
children: <Widget>[
// new Flexible(
new TextField(
style: new TextStyle(
color: Colors.white,
fontSize: 16.0),
cursorColor: Colors.green,
decoration: new InputDecoration(

suffixIcon: new IconButton(
icon: new Image.asset('assets/search_icon_ivory.png'),onPressed: null),

fillColor: Colors.black,
contentPadding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
filled: true,
hintText: 'What Do You Need Help With?',
hintStyle: new TextStyle(
color: Colors.white
)
)
)
// )
]
),

最佳答案

您可以使用半径 = 文本字段高度/2 或您喜欢的任何高度的圆形头像。

要了解文本字段规范,您可以访问 material.io

所以代码块将如下所示:

CircleAvatar(
radius: 30,
backgroundColor: Color(0xff94d500),
child: IconButton(
icon: Icon(
Icons.search,
color: Colors.black,
),
onPressed: () {
...
},
),
),

这样你就可以得到一个带有背景颜色的图标按钮。希望对大家有所帮助。

Icon button with background

关于flutter - 如何为图标按钮设置背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52777164/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com