颤振:循环下拉列表未显示所选值

时间:2019-02-12 02:06:10

标签: android mobile flutter dropdown hybrid-mobile-app

我正在制作一个for循环,以重复一个内部具有下拉菜单的小部件。但是,当我单击时未显示所选值时。有人以前曾经按下过下拉按钮吗? 这是我到目前为止的代码。它放置在for循环中。

child: new DropdownButton(

                value: _relationSelects[i],
                hint: Text("Select Category"),
                items: _relationschoice.map((String value) {
                return new DropdownMenuItem<String>(
                value: value,
                  child: new Text(value.toString()),
                );
                }).toList(),
                onChanged: (String value) {
                  setState(() {
                    _relationSelects[i] = value;      // Problem here too, the element doesn’t show in the dropdown as selected
                    print("Selected: ${_relationSelects[i]} (${i})");
                  });
                },


              ),

它可以打印选择的值。但这并没有改变状态。

如果我使用String代替List-String作为值,则它可以为所有循环下拉列表显示相同的选定值,这是不正确的。

我之前已经检查过此答案,但仍无法正常工作 Can't show the dropdown selected value in Flutter

有人可以建议吗?谢谢。

0 个答案:

没有答案
相关问题