I am doing to do app as a practice, so I have some TextField widgets, one of them is to show my dropdown list when pressed on TextField. I understand that I should use some onTap() or GestureDetector, but I am not getting how exactly I should show ANY widget on a click.
Container buildDropdownContainer() {
return Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: const Color.fromARGB(255, 70, 70, 70),
),
child: TextField(
readOnly: true,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.priority_high_outlined,
color: Colors.orange,
),
border: InputBorder.none,
hintText: "Priority",
),
onTap: () {},
),
);
}
return DropdownButton(
padding: EdgeInsets.symmetric(horizontal: 50),
hint: Text("Priority"),
value: dropdownValue,
onChanged: (value) {
setState(() {
dropdownValue = value!;
});
},
items: dropdownList.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e),
);
}).toList(),
);
So the question is: How to show up my dropdown list by pressing my textfield?
2
Answers
you can use flutter_typeahead for dropdown on tap of textfield
Try below code hope its help to you.
Variables:
UI