I am trying to use a drop down for my flutter app but I always get the error
The argument type 'void Function(String)' can't be assigned to the parameter type 'void Function(String?)?'.
Widget _lineOfBusinessRow(){
return Container(
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
DropdownButton<String>(
value: _lineOfBusinessValue,
onChanged: (String value){
setState(() {
_lineOfBusinessValue = value;
});
},
items: _lineOfBusinessItems.map<DropdownMenuItem<String>>((value){
return DropdownMenuItem(child: Text(value),
value: value);
}).toList(),
)
],
)
);
}
This is my code at the moment and this is the screenshot of the error:
Other than that, I have also tried doing this:
onChanged: (String? value){
setState(() {
_lineOfBusinessValue = value!;
});
},
If I remove the String or the question mark, I would be prompted to add a null check to 'value' and that leads to this error:

