我想更改弹出菜单按钮窗口的背景颜色。我应该怎么办?我希望我能得到你的帮助。谢谢。当我改变容器的颜色时,有些角落不能改变颜色。
new IconButton(
icon: new Icon(
Icons.search,
color: Colors.white,
),
onPressed: () {},
),
new PopupMenuButton(
offset: const Offset(0.0, 60.0),
icon: new Icon(Icons.add, color: Colors.white),
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
value: '选项一的值',
child: new Container(
color: Colors.red,
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Image.asset(defaultAvatar,
width: 30.0, height: 30.0),
new Text('发起群聊')
],
),
],
))),
new PopupMenuItem<String>(
value: '选项一的值',
child: new Container(
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Image.asset(defaultAvatar,
width: 30.0, height: 30.0),
new Text('添加朋友')
],
),
],
))),
最佳答案
该背景颜色基于 Theme
,因此您可以更改 PopMenuButton
内 Theme
的颜色并更改 卡片颜色
.
Theme(
data: Theme.of(context).copyWith(
cardColor: Colors.red,
),
child: new PopupMenuButton(
...
关于flutter - 如何更改 Popup MenuButton 弹窗的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53662200/