Reputation: 81
how can I make like this drop down menu in flutter ??
and how to add any item into that menu ??
Upvotes: 0
Views: 277
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