问题描述
当我将它保存在 AppBar 中时它正在工作。但是在 ListTile 中它不起作用。
它在调试版本中有效,但在发布版本中无效。我可以知道具体是什么问题吗..
在我的情况下,当我添加 PopupMenuButton 时,按钮本身没有显示在发布版本中。
Widget popupMenu() {
return PopupMenuButton(
color: Colors.white,icon: Icon(
Icons.more_vert,size: 30,color: Colors.black,),onSelected: (value) {
//conditions check
},itemBuilder: (context) => [
PopupMenuItem(
value: 'Message',child: Text(
'Message',)),]);
}
解决方法
就我而言,问题出在 ListTitle PopupMenuButton 没有被占用。我添加了一行,并在一行内添加了具有宽度和 PopupMenuButton 的 ListTitle 容器。
@override
Widget build(BuildContext context) {
return new Column(
children: <Widget>[
new Container(
child: Align(
alignment: Alignment.centerLeft,child: new Row(
children: <Widget>[
new Container(
width: MediaQuery.of(context).size.width - 50,child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,children: <Widget>[
ListTile(
dense: true,),],popupMenu(aspirantCardVO),)
],);
}
Widget popupMenu() {
return PopupMenuButton(
color: Colors.white,icon: Icon(
Icons.more_vert,size: 30,color: Colors.black,onSelected: (value) {
//conditions check
},itemBuilder: (context) => [
PopupMenuItem(
value: 'Message',child: Text(
'Message',)),]);
}