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

Viewed 2032
DropdownButton<String>(
              value: value,
              items: locationItems.map( DropdownMenuItem<String>(
                child: Text( widget.locationName ),
                value: "${widget.locationName}",
              )
              ),

2 Answers

Map returns iteratable. Try to convert it to list.

DropdownButton<String>(
              value: value,
              items: locationItems.map( DropdownMenuItem<String>(
                child: Text( widget.locationName ),
                value: "${widget.locationName}",
              )
              ).toList<DropdownMenuItem<String>>(),

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

Make your declared variable as the type above will solve your poblem

Related