How can I populate data for dropdownbutton2 with data from a json array here is a sample of the json in flutter
"data": [
{
"id": "1",
"name": "Floral"
},
{
"id": "4",
"name": "Marigold"
},
{
"id": "104",
"name": "Tulip"
}
]
How can i get the values of name to be displayed in the dropdown selection but the id will be selected in the onchange function
List dataList = [];
setState(() {
dataList = jsonData;
});
items: dataList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item['name'],
style: const TextStyle(
fontSize: 14,
color: Colors.black,
),
overflow: TextOverflow.ellipsis,
),
))
.toList(),
onChanged: (value) {
item['id'],
}),
``