dropdownbutton flutter code example

Example 1: dropdown button flutter example

DropdownButton(
                value: 'Dept1',
                elevation: 16,
                icon: Icon(Icons.arrow_drop_down_circle),
                isExpanded: true,
                items: ['Dept1','Dept2'].map((e) {
                  return DropdownMenuItem(
                    value: e,
                    child: Text(e) ,
                  );
                }).toList(),
              onChanged: (value){},
              ),

Example 2: flutter dropdownbutton stackoverflow

DropdownButton(
    isExpanded: true, //Step 1
    items: [
        new DropdownMenuItem(
            child: Text("Long text that overflow the size.. wrapped or ellipsized", 
            overflow: TextOverflow.ellipsis),  //Step 2
        ),
    ],
    onChanged: (val) { }
)

Tags:

Misc Example