【问题标题】:In a ListTitle PopupMenuButton works in debug but not in release mode in flutter在 ListTitle 中,PopupMenuButton 在调试中工作,但在颤振中不在发布模式下
【发布时间】:2021-04-13 00:04:47
【问题描述】:

当我将它保存在 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',
                  )),
            ]);
  }

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies popupmenubutton


    【解决方案1】:

    在我的情况下,问题在于 ListTitle PopupMenuButton 没有使用。我添加了一行,并在一行内添加了 ListTitle 容器,其中包含宽度和 PopupMenuButton。

     @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',
                      )),
                ]);
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多