How to not show the selected item in the dropdown?
I m using DropdownButtonHideUnderline package in flutter to implement a dropdown but i don’t want to show the selected item on the top.And i just need the selected item in a variable .How to do this?
Please help..
DropdownButtonHideUnderline(
child: DropdownButton2(
// Initial Value
value: dropdownValue,
// Down Arrow Icon
icon: const Icon(
Icons.more_vert,
color: Colors.white,
),
// Array list of items
items: items.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
),
);
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
dropdownValue = newValue!;
});
},
))
2
Answers
here you change the selected value:
by removing
your dropdown will not change.
and you can use the chosen value by
You can ignore setting value on
onChanged
,here, remove this, this is used to update the value on dropdownButton
.