fares
fares

Reputation: 81

how to make drop down menu Flutter

how can I make like this drop down menu in flutter ??

and how to add any item into that menu ??

enter image description here

Upvotes: 0

Views: 277

Answers (1)

pedro pimont
pedro pimont

Reputation: 3074

There's a Widget called DropDownButton. For more information check out the docs for that Widget. You can add items to the menu by passing a List<DropdownMenuItem<T>> to it's items parameter.

DropdownButton<String>(
      value: dropdownValue,
      icon: Icon(Icons.arrow_downward),
      iconSize: 24,
      elevation: 16,
      style: TextStyle(color: Colors.deepPurple),
      underline: Container(
        height: 2,
        color: Colors.deepPurpleAccent,
      ),
      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(),
    );

Upvotes: 1

Related Questions