Chciałbym przekazać index wybranego menu z DropdownButtonFormField tak, żeby móc go użyć przy wyborze indexu posta (zamiast 0) albo w jakiś sposób dobrać się do posts.nazwa...
Czy może mi ktoś powiedzieć jak to zrobić?
DropdownButtonFormField(
hint: const Text("Wybierz jadłospis", style: TextStyle(color: Colors.black, fontSize: 16.0, fontStyle: FontStyle.italic)),
items: posts.map((item) {
return DropdownMenuItem(
value: item.id.toString(),
child: Text(item.nazwa.toString().substring(0, showLenght(item.nazwa.toString().length)), style: const TextStyle(color: Colors.black, fontSize: 16.0, fontStyle: FontStyle.italic)),
);
}).toList(),
onChanged: (newValue) {
setState(() {
print(newValue);
_listName = posts[0].nazwa.toString();
_description = posts[0].opis.toString();
_email = posts[0].dietetyk.toString();
});
},