首页 > 解决方案 > 处理颤动中动态可扩展列表的项目点击

问题描述

我在动态列表中有动态列表,我需要用它们的属性保存选项。我尝试了很多方法来显示每个选项的属性下拉列表,但DropDownMenuitemWidgets 不处理稳定版本的 Flutter 中的动态列表,因此我必须为此目的使用 Expandable List。当我选择一个选项的属性时,如何在标题中反映对特定选项的选择,或者如何保存对动态属性的选择

这就是我建立我的清单的方式

ListView.builder(
                shrinkWrap: true,
                itemCount: opAtrrList.length>0?opAtrrList.length:0,
                itemBuilder: (context, i) {
                  return ExpansionTile(
                    title:optionTitle(width,height,opAtrrList[i].groupname,selectedAttr),
                    children: <Widget>[
                      new Column(
                        children: _buildExpandableContent(opAtrrList[i]),
                      ),
                    ],
                  );
                },
              ),

这是我的可扩展项目Attribute selectedAttr;

_buildExpandableContent(OptionAttribute oa) {
      List<Widget> columnContent = [];
      for(int i=0;i<oa.attrlist.length;i++){
        columnContent.add(
          new ListTile(
            onTap: (){
              setState(() {
                selectedAttr=oa.attrlist[i];
              });
            },
            title: new Text(oa.attrlist[i].attributename, style: TextStyle(fontFamily: 'medium',color: MyColors.colorPrimaryDark)),
          ),
        );
      }
      return columnContent;
    }

请看下面的gif。

在此处输入图像描述

标签: androiddartflutter

解决方案


推荐阅读