可以通过自定义AppBar的样式来编辑AppBar图标的背景色。可以使用AppBar的backgroundColor属性来设置AppBar整体的背景色,使用leading和actions属性来设置AppBar中的图标,再使用IconButton的color属性来设置图标的颜色。
示例代码:
AppBar(
backgroundColor: Colors.red, //设置AppBar背景颜色
leading: IconButton(
icon: Icon(Icons.menu), //设置leading图标
color: Colors.white, //设置图标颜色
onPressed: () {},
),
actions: [
IconButton(
icon: Icon(Icons.search), //设置actions图标
color: Colors.white, //设置图标颜色
onPressed: () {},
),
],
)