首页 > 解决方案 > 如何让 DropdownButtonFormField 显示我保存在数据库中的值的输出

问题描述

我正在使用 DropdownButtonFormField 并且到目前为止列表正在加载我,但我希望您加载列表并加载保存在我的数据库中的项目并将其作为输出显示给我,表明用户已经选择了以前的项目。

这是我正在使用的代码

                               DropdownButtonFormField(
                                isDense: true,
                                //hint: new Text("Seleccione Barrio"),
                                items: dataBarrio.map((item) {
                                  return new DropdownMenuItem(
                                    child: new Text(item['nom']),
                                    value: item['id'].toString(),
                                  );
                                }).toList(),
                                onChanged: (newVal) {
                                  setState(() {
                                    _mySelectionBarrio = newVal;
                                  });
                                },
                                value: _mySelectionBarrio,
                              )

标签: flutter

解决方案


推荐阅读