Couldn't infer type parameter 'T'.
Tried to infer 'dynamic' for 'T' which doesn't work:
Parameter 'onChanged' declared as 'void Function(T?)?' but argument is 'void Function(Object?)'.
The type 'dynamic' was inferred from:
Parameter 'value' declared as 'T?' but argument is 'String'. Parameter 'items' declared as 'List<DropdownMenuItem>?' but argument is 'List<DropdownMenuItem>'.
Consider passing explicit type argument(s) to the generic.
I have DropDownformfield which shows above problem The code is
SizedBox(
width: deviceWidth * .9,
height: deviceHeight * 0.15,
child: DropdownButtonFormField(
value: _dropDownValue,
dropdownColor: Colors.blueAccent,
iconSize: deviceWidth * .05,
icon: Icon(
Icons.arrow_drop_down_circle,
color: Colors.white,
),
style: TextStyle(
color: Colors.black,
fontFamily: 'Constantia',
fontSize: 18.0,
),
autovalidateMode: AutovalidateMode.always,
decoration: InputDecoration(
enabled: true,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
width: 2,
style: BorderStyle.solid,
),
),
),
onChanged: (value) {
setState(() {
_dropDownValue = value.toString();
print(_dropDownValue);
});
},
items: <DropdownMenuItem<dynamic>>[
menuItem('none'),
menuItem('10'),
menuItem('20'),
menuItem('30'),
menuItem('40'),
menuItem('50'),
menuItem('60'),
menuItem('70'),
menuItem('80'),
menuItem('90'),
menuItem('100'),
],
),
),
And widget as
DropdownMenuItem menuItem(String val) {
final deviceWidth = MediaQuery.of(context).size.width;
return DropdownMenuItem<String>(
value: val,
child: Container(
width: deviceWidth * 0.6,
child: Text(
val,
style: TextStyle(
fontFamily: 'Constantia',
fontSize: 18.0,
color: Colors.white,
),
),
),
);
The Code works fine but Android Studio displays this as a problem.