我遇到的问题是方法“showModalBottomSheet”在弹出菜单项的“onTap”函数中不起作用。单击弹出菜单条目时,不显示模态底部表。
这是我在 AppBar 的 actions 参数中的代码:
actions: [
PopupMenuButton(
itemBuilder: (BuildContext context) => choices
.map((Choice choice) => PopupMenuItem<Choice>(
child: Row(
children: [
choice.icon,
SizedBox(width: 15),
Text(choice.text),
],
),
value: choice,
onTap: () {
print('Modal Bottom Sheet should open.');
showModalBottomSheet(
context: context,
builder: (context) {
return Container(
color: Colors.transparent,
height: 184,
);
},
);
},
))
.toList())
],
感谢您的任何帮助。