【发布时间】:2021-11-06 00:24:37
【问题描述】:
我正在学习一个教程,但我在地图上出现错误我不知道为什么,在我看来我做得对
这是我的清单
var questions = [
{
'questiontext': "Questão 1",
'answer': [
{'text': 'Black', 'score': 10},
{'text': 'Red', 'score': 5},
{'text': 'Green', 'score': 3},
{'text': 'White', 'score': 1},
]
},
{
'questiontext': "Questão 2",
'answer': {
{'text': 'Rabbit', 'score': 3},
{'text': 'Snake', 'score': 11},
{'text': 'Elephant', 'score': 5},
{'text': 'Lion', 'score': 9},
},
},
{
'questiontext': "Questão 3",
'answer': {
{'text': 'Peter', 'score': 1},
{'text': 'Paul', 'score': 1},
{'text': 'Max', 'score': 1},
},
}
];
我的飞镖代码
final List<Map<String, Object>> questions;
...(questions[0]['answer'] as List<Map<String, Object>>)
.map((answer) {
return Answer(() => textfunction(answer['score']), answer['text']);
}).toList()
错误
参数类型“对象?”不能分配给参数类型 'String'.dart(argument_type_not_assignable)
参数类型“对象?”不能分配给参数类型 'int'.dart(argument_type_not_assignable)
我不知道怎么了。我已经尝试切换到动态,它一直报错
【问题讨论】: