praveen
praveen

Reputation: 11

The argument type 'List<Widget>' can't be assigned to the parameter type 'List<String>?'

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

Answers (1)

Ravi Limbani
Ravi Limbani

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

Related Questions