1

I'm trying to build a form with a DropdownButtonFormField with 4 items but i don't know why it doesn't want to expand.

Added isDense : true but it wasn't because of it being too small

Here's the button code

new Container(
    child: DropdownButtonFormField(
        isDense: false,
        hint: Text('Ecole'),
        onSaved: (value) {
            this._data.ecole = value.toString();
           },
        items: ['HEI', 'ISEN', 'ISA', 'all'].map((String value) {
            return DropdownMenuItem(
                value: value,
                child: Text(value),
               );
           }).toList()),
         ),

1

Dinesh Nagarajan
  • 1,063
  • 2
  • 10
  • 22
Rafien
  • 23
  • 3

1 Answers1

0

Try this

String dropdownValue = 'HEI';
DropdownButton<String>(
        value: dropdownValue,
        icon: const Icon(Icons.arrow_downward),
        iconSize: 24,
        elevation: 16,
        style: const TextStyle(color: Colors.deepPurple),
        underline: Container(
          height: 2,
          color: Colors.deepPurpleAccent,
        ),
        onChanged: (String? newValue) {
          setState(() {
            dropdownValue = newValue!;
          });
        },
        items: <String>['HEI', 'ISEN', 'ISA', 'all']
            .map<DropdownMenuItem<String>>((String value) {
          return DropdownMenuItem<String>(
            value: value,
            child: Text(value),
          );
        }).toList(),
      ),
Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40