Reputation: 1953
From below code i able to add padding to hint(placeholder), but i'm not able to add padding for selected drop Down item
DropdownButtonHideUnderline(
child: DropdownButton(
isExpanded: true,
hint: Padding(
padding: const EdgeInsets.only(left: 10),
child: 'Sort By,
),
items: getDropDownMenuItems(["Name", "Class"]),
value: myActivity,
style: TextStyle(color: Colors.green),elevation: 10,
onChanged: (String value) => {
setState(() {
myActivity = value;
}),
sortList(value)
}),
);
getDropDownMenuItems(options) {
var items = List<DropdownMenuItem<String>>();
for (String option in options) {
items.add(DropdownMenuItem(value: option, child: Text(option)));
}
return items;
}
I want left side padding for selected drop down item
Upvotes: 0
Views: 121
Reputation: 7209
Try to use Padding for the child of your dropdown
getDropDownMenuItems(options) {
var items = List<DropdownMenuItem<String>>();
for (String option in options) {
items.add(DropdownMenuItem(value: option, child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(option),
);));
}
return items;
}
Upvotes: 2