I have built a dropdown which has a dropdown list. The item that is selected from the list should be passed to another page, hence, I have used the TextEditingController variable to do that. But the problem is that the dropdown button doesn't allow us to use the TextEditingController. My code is below:
TextEditingController _name = new TextEditingController();
String ? valueChoose;
List listItem = ["A", "B", "C", "D"];
DropdownButton<String>(
underline: SizedBox(),
hint: Text('Example'),
dropdownColor: Colors.white,
isExpanded: true,
icon: Icon(Icons.arrow_drop_down),
iconSize: 40.0,
value: valueChoose,
onChanged: (String ? newValue) {
setState(() {
valueChoose = newValue!;
});
},
items: listItem.map<DropdownMenuItem<String>>((valueItem){
return DropdownMenuItem(
value: valueItem,
child: Text(valueItem),
);
}).toList(),
),
Please suggest how can I achieve this. Thanks in advance!