在此简单的实现代码中,我向PopupMenuButton
动作参数中添加了AppBar
项,现在我想对具有默认颜色的PopupMenuDivider
颜色进行样式设置。
我尝试使用ThemeData
,但出现错误:
ThemeData(
child: const PopupMenuDivider(
height: 10,
),
),
我的代码:
PopupMenuButton<int>(
onSelected: null,
icon: const Icon(Icons.more_vert),
color: const Color(0xFF32313C).withOpacity(0.9),
elevation: 8.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
itemBuilder: (context) {
final list = <PopupMenuEntry<int>>[];
list.add(
PopupMenuItem(
child: Row(
children: [
Icon(Icons.add, color: Colors.white),
Text(
"InduceSmile.com",
style: TextStyle(color: Colors.white),
).pl(16.0),
],
),
),
);
list.add(
const PopupMenuDivider(
height: 10,
),
);
return list;
},
offset: Offset(0, 100),
)
答案 0 :(得分:1)
用DividerThemeData
将MaterialApp
包裹在ThemeData
内,并选择dividerColor
。
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
dividerTheme: DividerThemeData(
color: Colors.black
)
),
);
}
}