Flutter - The method 'map' was called on null
I had a similar issue, solved by wrapping it in a condition that was checking whether list had more than 0 items.
Pass an empty container while listProvices
is null
:
items: listProvices?.map((Provinces value) {
return new DropdownMenuItem<Provinces>(
value: value,
child: new Text(value.name, style: new TextStyle(fontSize: 16.0),),
);
})?.toList() ?? [],