Home > OS >  Custom height with scroll on a dropdown
Custom height with scroll on a dropdown

Time:01-05

So I have a dropdown widget but when the list increases the dropdown increases. How can I avoid this? I for e.g I want to make it 400 height max and have a scroll inside. Also is it possible to add a placeholder instead of adding a value as first selected?

enter image description here

child: DropdownButtonHideUnderline(
                    child: DropdownButton(
                        dropdownColor: Colors.white,
                        isExpanded: true,
                        value: dropdownValue,
                        focusColor: Colors.white,
                        items: [
                          'Country',
                          'B',
                          'C',
                          'D',
                          'E',
                          'A',
                          'B',
                          'C',
                          'D',
                          'E'
                        ].map((String value) {
                          return DropdownMenuItem(
                              value: value, child: Text(value));
                        }).toList(),
                        onChanged: (_) {}),
                  ),

CodePudding user response:

You can use menuMaxHeight:400 to set Custom height.

DropdownButtonHideUnderline(
  child: DropdownButton(
    menuMaxHeight: 400,
  •  Tags:  
  • Related