I'm having the error The argument type 'Color Function(String)' can't be assigned to the parameter type 'dynamic Function(dynamic)'
in this line:
final colors = data.map(getColorFromCode);
Here is the data
:
late final data = [
widget.result,
widget.result2,
widget.result3,
];
Here is the function 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;
}
How to solve this error? If you need any additional details feel free to ask.
CodePudding user response:
try giving the data type to you data
list
like this
final List<String> data = [widget.result,
widget.result2,
widget.result3,];