Home > OS >  How to increase white space in between the text and the arrow in a DropdownButton in flutter?
How to increase white space in between the text and the arrow in a DropdownButton in flutter?

Time:11-19

DropdownButton(
  value: dropDownValue1,
  onChanged: (String? newValue) {
    setState(() {
      dropDownValue1 = newValue!;
    });
  },
  items: <String>[
    'Work At Office',
    'Work From Home',
  ].map<DropdownMenuItem<String>>((String value) {
    return DropdownMenuItem<String>(
      value: value,
      child: Text(value),
    );
  }).toList(),
)

how to increase space between the arrow and the text

Now

I hope I can make it be like this, how to do it?

Desired output

Thanks in advance

CodePudding user response:

Just add isExpanded: true, under the dropdown for expanding icon

DropdownButton(
  isExpanded: true, // here need to change
  value: dropDownValue1,
  onChanged: (String? newValue) {
    setState(() {
      dropDownValue1 = newValue!;
    });
  },
  items: <String>[
    'Work At Office',
    'Work From Home',
  ].map<DropdownMenuItem<String>>((String value) {
    return DropdownMenuItem<String>(
      value: value,
      child: Text(value),
    );
  }).toList(),
)

Output:

enter image description here

CodePudding user response:

Try below code hope its helpful to you. refer my answer enter image description here

  • Related