The argument type 'List<dynamic>' can't be assigned to the parameter type 'List<DropdownMenuItem<String>>?'.
// List with fields to be displayed in dropdown
final List itemsList
DropdownButton<String>(
value: selectedItem,
icon: const Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
// call event with select value
},
items: convertList())
// Converting List to List<DropdownMenuItem<String>>
List<DropdownMenuItem<String>> convertList() {
List<DropdownMenuItem<String>> list = [];
for (var item in itemsList) {
list.add(DropdownMenuItem(
child: Text(item),
value: item,
));
}
return list;
}