[英]How can i change the width/padding of a Flutter DropdownMenuItem in a DropdownButton?
[英]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 的下拉菜单中实现全宽度。
删除Expanded
和Container
并按照下面给出的代码
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.