参考
参考代码
Center(
child: Theme(
data: Theme.of(context).copyWith(
cardColor: Colors.greenAccent,
),
child: PopupMenuButton<int>(
onSelected: (value) {
},
offset: Offset(50, 50),
itemBuilder: (context) => [
PopupMenuItem(
value: 1,
child: Container(
height: double.infinity,
width: double.infinity,
color: Colors.greenAccent, // i use this to change the bgColor color right now
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Icon(Icons.check),
SizedBox(width: 10.0),
Text("Konfirmasi Update"),
SizedBox(width: 10.0),
],
),
),
)
]
)
)
)
参考
用到Theme的ThemeData的cardColor,定义一个独立的 ThemeData,不想从任何全局 Theme 继承样式
Theme(
data: ThemeData(
cardColor: const Color(0xFF0E111A),
),
child: PopupMenuButton(
offset: const Offset(0.0, 50.0),
child: Row(children: [
Expanded(
child: ContentText(
'$currentGiftCount',
12.0,
Colors.white)),
Image(
image: const AssetImage('assets/images/group/icon_group_upward_arrow.png'),
width: WidgetAdaptation.getWidth(10),color: const Color(0xFFD159FD),)
]),
onSelected: (int value) {
currentGiftCount = value;
mySetState(() {
});
},
itemBuilder: (BuildContext context) {
return _getCountContents;
}),
)
List<PopupMenuItem<int>> get _getCountContents {
List<PopupMenuItem<int>> contents = [];
contents.add(PopupMenuItem<int>(
child: ContentText('1', 16, Colors.white), value: 1));
contents.add(PopupMenuItem<int>(
child: ContentText('66', 16, Colors.white), value: 66));
contents.add(PopupMenuItem<int>(
child: ContentText('88', 16, Colors.white), value: 88));
contents.add(PopupMenuItem<int>(
child: ContentText('99', 16, Colors.white), value: 99));
contents.add(PopupMenuItem<int>(
child: ContentText('666', 16, Colors.white),
value: 666));
contents.add(PopupMenuItem<int>(
child: ContentText('888', 16, Colors.white),
value: 888));
contents.add(PopupMenuItem<int>(
child: ContentText('999', 16, Colors.white),
value: 999));
return contents;
}