flutterdartdropdownbuttonflutter-dropdownbutton

How to increase height for a DropdownButton in Flutter


I do have a DropdownButton and all I want is to increase the height of it just a little bit to be able to see minimum 2 lines of text when the user select an option from the list. I already tried with Container, SizedBox and Padding, but nothing worked or maybe I was doing something wrong. This is my code:

Padding(
        padding: const EdgeInsets.only(bottom: 30),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          mainAxisSize: MainAxisSize.min,
          children: [
            const Text("Dropdown options"),
            Expanded(
              child: DropdownButton(
                value: currentOptionIDSelected.toString(),
                isExpanded: true,
                isDense: true,
                items: optionsList.map((OptionModel option) {
                  return DropdownMenuItem(
                    value: option.optionID,
                    child: Text(option.name ?? ""),
                  );
                }).toList(),
                onChanged: (String? newOptionID) {
                  setState(() { },
                padding: const EdgeInsets.only(left: 40),
                style: const TextStyle(fontSize: 14, height: 1),
              ),
            ),
          ],
        ),
      ),

Here is a screenshot of how it looks for the moment: enter image description here

Thanks for reading this !


Solution

  • I found the solution for my issue. To increase the height of the DropdownButton you need to set 3 properties: