Flutter
[Flutter] dropdown button text align to center
hymndaniel
2022. 5. 4. 08:44
set property isExpanded to true
use Center widget with DropdownMenuItem class children.
IsExpanded will also take care of overflow.
DropdownButton(
isExpanded: true,
value: category_selected,
items: categories.map<DropdownMenuItem<String>>((var value) {
return DropdownMenuItem<String>(
value: value["name"],
child: Center(
child: Text(
value["name"],
textAlign: TextAlign.center,
),
),
);
}).toList(),
),
Reference
https://stackoverflow.com/questions/56787244/how-to-center-text-in-dropdownbutton
How to center text in DropdownButton?
I'm trying to make the DropdownButton hint, text and menu items appear in the center instead of left but TextAlign.center does not seem to be doing anything. Image of Dropdown with the hint: Imag...
stackoverflow.com
728x90