![](/img/trans.png)
[英]Flutter(dart) error: The argument type can't be assigned to the parameter type 'dynamic Function(List<Student>?)'
[英]Flutter error: The argument type 'Color Function(String)' can't be assigned to the parameter type 'dynamic Function(dynamic)'
我有错误The argument type 'Color Function(String)' can't be assigned to the parameter type 'dynamic Function(dynamic)'
:
final colors = data.map(getColorFromCode);
这是data
:
late final data = [
widget.result,
widget.result2,
widget.result3,
];
这是函数getColorFromCode
:
Color getColorFromCode(String code) {
if (code.contains('A') && code.contains('P')) return Colors.brown;
if (code.contains('A') && code.contains('pp')) return Colors.black;
if (code.contains('aa')) return Colors.white;
return Colors.black;
}
如何解决这个错误? 如果您需要任何其他详细信息,请随时询问。
尝试将数据类型提供给您的data
列表
像这样
final List<String> data = [widget.result,
widget.result2,
widget.result3,];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.