'from dropdownmenu to dropdownsearch in flutter

I was using normal dropdown menu in my project with small amount of data fetched from my api, but now i have menu which could reach hundred of values and make it hard to select an item. That's why i wanted to use DropDownSearch but instead i get an error

Normal dropdown code which works very fine

 DropdownButton(
              showSearchBox: true,
              showSelectedItem: true,
              items: data3.map((item) {
                return new DropdownMenuItem(
                  child:  Text(item['first_name']+" "+ item['last_name']),
                  value: item['emp_code'].toString(),
                );
              }).toList(),
              onChanged: (newVal) {
                setState(() {
                  _mySelection3 = newVal.toString();
                });
              },
              value: _mySelection3,
            ),

data3 = [{emp_code: 111, first_name: adnen, last_name: hamouda}, {emp_code: 666, first_name: ahmed, last_name: ahmed 99}....

this is the result: normal dropdown

But when i tried to convert it to dropDownSearch i got this result: search dropdown I want to show the first_name and last_name like the normal dropdown but save the value of their 'emp_code' which i will be using in another api later. How can i fix it ?

 DropdownSearch(
              mode: Mode.DIALOG,
              showSearchBox: true,
              items: data3.map((item) {
                return new DropdownMenuItem(
                  child:  Text(item['first_name']+" "+ item['last_name']),
                  value: item['emp_code'].toString(),
                );
              }).toList(),
              onChanged: (newVal) {
                setState(() {
                  print(data3);
                  _mySelection3 = newVal.toString();
                });
              },
              selectedItem: _mySelection3,

            ),


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source