我想给每个容器给予颜色。我试着把它 Package 在一个容器里,然后分配颜色,但它没有给整个物品容器着色。我试过所有可能的方法,但它不起作用。enter image description here
PopupMenuButton<String>(
itemBuilder: (BuildContext context) {
return <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'option1',
child: ListTile(
leading: Icon(Icons.delete),
title: Text('Delete'),
),
),
PopupMenuDivider(),
PopupMenuItem<String>(
value: 'option2',
child: ListTile(
leading: Icon(Icons.edit),
title: Text('Edit'),
),
),
PopupMenuItem<String>(
value: 'option3',
child: ListTile(
leading: Icon(Icons.share),
title: Text('Share'),
),
),
];
},
onSelected: (String value) {
// Handle the selected option
switch (value) {
case 'option1':
// Perform delete operation
break;
case 'option2':
// Perform edit operation
break;
case 'option3':
// Perform share operation
break;
}
},
)
];
字符串
1条答案
按热度按时间1aaf6o9v1#
实现此目的的一种方法是使用
Container
post Package 每个PopupMenuItem
的子对象,您可以设置该Container
的color
属性。类似于:字符串