Reputation: 11
My dart
List<Widget> getcategoryname() {
List<Widget> category_name = categorynameController.CategoryNameList
.map((e) {
var index = categorynameController.CategoryNameList.length;
print(index);
for (int i = 0; i < index; i++) {
var name = e.name.toString();
print(name);
return Text(name);
}
})
.cast<Widget>()
.toList();
return category_name;
}
Widget pet_category()=>DropdownSearch<String>(
mode: Mode.MENU,
items: getcategoryname(),
label: "Menu mode",
hint: "country in menu mode",
popupItemDisabled: (String s) => s.startsWith('I'),
onChanged: print,
selectedItem: "Brazil");
i am using dropdown_search 2.0.1 plugin items:getcategoryname() show error how to fix this error**
Upvotes: 1
Views: 1605
Reputation: 1172
You cannot use List<Widget>
inplace of List<String>
in items field.You need to use list which contain String. Currently you use Text() List and Text is Widget. You need to use items like this
items: con.mainCategoryList.map((value) {
return value.categoryName!;
}).toList(),
Upvotes: 1