无法推断类型参数“T”。
试图推断“T”的“动态”,但这不起作用:
参数“onChanged”声明为“void Function(T?)?” 但参数是“void Function(Object?)”。
类型“动态”是从以下内容推断出来的:
参数“值”声明为“T?” 但参数是“字符串”。参数“items”声明为“List<DropdownMenuItem>?” 但参数是“List<DropdownMenuItem>”。
考虑将显式类型参数传递给泛型。
我有 DropDownformfield 显示上述问题代码是
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>>[ …Run Code Online (Sandbox Code Playgroud)