-1

how to add margin in dropdown item menu? i want to add space in every menu item

here is my code

// Dropdown Box
        Container(
         .....
          child: DropdownButton(
            elevation: 1,
            isExpanded: true,
            hint: Text(
              '--Select One--',
              style: TextStyle(
                color: Color(0xffB2B2B2),
              ),
            ),
           
            items: dropdownOption.map((e) {
              return DropdownMenuItem(
                value: e['value'],
                child: Text(e['label']),
              );
            }).toList(),
            value: dropdownValue,
            onChanged: (value) {
              setState(() {
                dropdownValue = value;
              });

            },
          ),
        ),

enter image description here

if i put padding in text dropdown menu it looks like this

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44
CCP
  • 886
  • 1
  • 10
  • 30
  • Does this answer your question? [Custom Dropdown Button and MenuItems Flutter](https://stackoverflow.com/questions/59715001/custom-dropdown-button-and-menuitems-flutter) – Md. Yeasin Sheikh Mar 10 '22 at 10:27

3 Answers3

1

By simply wrapping your text widget with padding widget.

0

You can do that with DropdownButton2 by using itemPadding property. DropdownButton2 is based on Flutter's core DropdownButton with steady dropdown menu below the button and many other options you can customize to your needs.

Disclaimer: I am the author of the package mentioned above.

Ahmed Elsayed
  • 538
  • 1
  • 4
  • 11
0

it turns out it's really simple just add itemHeight in DropdownButton lol

example:

DropdownButton(
              itemHeight: 70,
),
CCP
  • 886
  • 1
  • 10
  • 30