Flutter DropdownButton Widget

Flutter DropDown button is a Material widget which will be used to display list of items or menu items as DropDown.
When we tap on DropDown button it will display all items and when we select any item that selected item will display on menu button.
DropDownButton has below properties

  • Items
  • selectedItemBuilder
  • value
  • hint
  • disabledHint
  • elevation
  • style
  • icon
  • iconDisabledColor
  • iconEnabledColor
  • iconSize
  • isExpanded
  • dropdownColor

 

String dropdownValue = 'One';


Widget build(BuildContext context) {
  return Scaffold(
    body: Center(
      child: DropdownButton<String>(
        value: dropdownValue,
        onChanged: (String newValue) {
          setState(() {
            dropdownValue = newValue;
          });
        },
        items: <String>['One', 'Two', 'Free', 'Four']
          .map<DropdownMenuItem<String>>((String value) {
            return DropdownMenuItem<String>(
              value: value,
              child: Text(value),
            );
          })
          .toList(),
      ),
    ),
  );
}

Subscribe For Daily Updates

Flutter Questions
Android Questions