I have a problem. Please help. I just started the program in a flutter. I want to display my array list(foto) to DropDownButton
.
array list in firebase ,
final List<String> listCategorys = FirebaseFirestore.instance
.collection('shoppingList')
.doc('category');
String categoryName = 'fruit';
DropdownButton<String>(
focusColor: Colors.white,
value: categoryName,
style: const TextStyle(color: Colors.white),
iconEnabledColor: Colors.black,
items: listCategorys
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Padding(
padding: const EdgeInsets.only(
left: 42,
),
child: Text(
value,
style: const TextStyle(
color: Colors.black,
fontSize: 18,
),
),
),
);
}).toList(),
hint: const Text(
"Select categories",
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.w500),
),
onChanged: (String? value) {
setState(() {
categoryName = value!;
});
},
),
when I create a rigid array final List<String> listCategorys = ['fruit', 'vegetables' ...]
it works, but I won't get all data in firebase