简体   繁体   English

如何在 Flutter 中显示 DropDownButton?

[英]How to show DropDownButton in Flutter?

I want to show dropdownlist/dropdownbutton programmatically, but not show anything.我想以编程方式显示下拉列表/下拉按钮,但不显示任何内容。 i dont know why not show it.我不知道为什么不显示它。 below my code.在我的代码下方。

           Container(
                height: 200.0,
                child: ListView.builder(
                    scrollDirection: Axis.vertical,
                    shrinkWrap: true,
                  itemCount: _mEmployeeList==null?0:_mEmployeeList.Length,
                    itemBuilder: (context,index)
                        {
                          print(_mEmployeeList[index].EMP_NAME);
                          DropdownButton(
                              items: [
                                DropdownMenuItem(
                                     value:_mEmployeeList[index].EMP_NAME,
                                     child: Text(_mEmployeeList[index].EMP_NAME)
                              ,
                                ),
                              ],
                            // value: _mEmployeeList[index].EMP_NAME,
                            onChanged: (sal){
                                setState(() {
                                  Fhelper.showToast(sal);
                                });
                            },
                          );
                        }
                ),
              ),

Yes, i will solve my problem.是的,我会解决我的问题。 thanks谢谢

Center( child: Row( children: [ DropdownButton( value:_mEmployeeList[0].EMP_OID, items:_mEmployeeList.map((index) { return DropdownMenuItem( child: new Text(index.EMP_NAME), value: index.EMP_OID, ); }).toList(), onChanged: (sal){ setState(() { Fhelper.showToast(sal); }); }, ), ], ), ),中心(子:行(子:[下拉按钮(值:_mEmployeeList[0].EMP_OID,项目:_mEmployeeList.map((索引){返回DropdownMenuItem(子:新文本(索引.EMP_NAME),值:索引.EMP_OID,) ; }).toList(), onChanged: (sal){ setState(() { Fhelper.showToast(sal); }); }, ), ], ), ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM