繁体   English   中英

flutter 中的 DropdownMenuItem 不是全宽?

[英]DropdownMenuItem not full width in flutter?

在此处输入图像描述

我想以任何方式在飞镖/颤振中设置全宽 100%。 但它没有在 flutter 的下拉列表中设置。 我的源代码在下面详细说明。

      Container(
                    height: 50,
                    width: 500.0,
                    // width: MediaQuery.of(context).size.width,
                    child: Expanded(
                      child: DropdownButtonHideUnderline(
                        child: ButtonTheme(
                          alignedDropdown: true,
                          child: DropdownButton(
                            isExpanded: true,
                            value: _selectionRetailer,
                            style: Theme.of(context).textTheme.bodyText1,
                            // items: mRetailList.map((index) {
                            items: mRouteWiseRetailList.map((index) {
                              return DropdownMenuItem(
                                alignment: Alignment.center,
                                child: new Text(
                                  index.retailerTitle + "_" + index.retailerAddress,
                                  style: TextStyle(fontSize: 10),
                                ),
                                value: index.retailerID,
                              );
                            }).toList(),

                            onChanged: (sal) {
                              setState(() {
                                mRetailer = sal;
                                _selectionRetailer = sal;
                                retailerID = sal;
                                print("SAVEDATADD" + "retailerID: $retailerID");
                                if (reasonID == "0") {
                                } else {
                                  startTime = Fhelper.CurrentDateTime();
                                  Fhelper.showToast(
                                      "RetailerID: $retailerID, StartTime: $startTime, salesOfficerID: $salesOfficerID");
                                  print("SAVEDATADD" +
                                      "RetailerID: $retailerID, StartTime: $startTime, salesOfficerID: $salesOfficerID,entryBy : $entryBy");
                                  clearAll();
                                }
                              });
                            },
                          ),
                        ),
                      ),
                    ),
                  ),

如何在 flutter 的下拉菜单中实现全宽度。

删除ExpandedContainer并按照下面给出的代码

DropdownButtonHideUnderline(
        child: ButtonTheme(
          alignedDropdown: true,
          child: DropdownButton(
            isExpanded: true,
            value: dropdownvalue,
            icon: Icon(Icons.keyboard_arrow_down),
            items:items.map((String items) {
              return DropdownMenuItem(
                  value: items,
                  child: Text(items)
              );
            }
            ).toList(),
            onChanged: (String newValue){
              setState(() {
                dropdownvalue = newValue;
              });
            },
          ),
        ),
      )

暂无
暂无

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

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