Hi I have a dropdown button whose hint and selected value text is cut off when too long:
It should be displaying "Department Code / Department Number"

Code:
DropdownButton<String> dropdownList(BuildContext context) {
return new DropdownButton<String>(
hint: new Text(
"Department Code / Department Number",
),
value: selectedDept,
isDense: true,
onChanged: (String newValue) {
//...
},
items: _item.map((Dept map) {
return new DropdownMenuItem<String>(
value: map.code,
child:
new Text(map.code, style: new TextStyle(color: Colors.black)),
);
}).toList(),
isExpanded: true,
);
}
Widget build(BuildContext context) {
return Scaffold(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(
20, 20, 10, 20),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
side: BorderSide(
width: 1.0,
style: BorderStyle.solid,
color: Colors.grey[400]),
borderRadius:
BorderRadius.all(
Radius.circular(
15.0)),
),
),
child:
DropdownButtonHideUnderline(
child: dropdownList(
context)),
)
]
)
)
}
Any idea how to fix the display?
If you dont want to increase the size of the dropdown, Change the content padding to something that suits you.
DropdownButtonFormField(
itemHeight: 50,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(vertical: 5, horizontal: 10),
.
.
.
Theres usually a default value for contentPadding which is cutting up your text. To access input decoration you'll need to use DropdownButtonFromField
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With