'flutter DropdownButtonFormField long item not fully displayed
when DropdownMenuItem is not fully displayed because of its height. so Im wonseringhow can I make the size change dynamically to fully display the chosen item
DropdownButtonFormField(
isExpanded: true,
validator: (value){
if(value== null){
return "Campo vuoto";
}
else {
return null;
}
},
decoration:InputDecoration(
labelText: "Locale",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(5))
)
) ,
onChanged: (value) {
setState(() {
chosenService = value.toString();
});
},
items: locals.map((local) => DropdownMenuItem(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(local.name,style: TextStyle(fontSize: 14, color: Color(Helper.getColorByType(local.type)), fontWeight: FontWeight.w400),
overflow: TextOverflow.visible),
Text(Helper.getAdressFromDescription(local.description), style: TextStyle(fontSize: 12, color: Colors.black54),
overflow: TextOverflow.ellipsis)
],
),
),
value: local.type+' - '+local.name,
),
).toList(),
),
Solution 1:[1]
I think that it can help you
SizedBox(
height: 100//I use default value as well but you can another value or MediaQuery
width: MediaQuery.of(context).size.width / x.x, //try ideal values
child: DropdownButtonFormField(
...
decoration: const InputDecoration(
border: InputBorder.none, contentPadding: EdgeInsets.all(0), ),
alignment: Alignment.bottomCenter,
...
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zekai Demir |
