【发布时间】:2021-01-07 17:59:21
【问题描述】:
我有一个键值对列表
我想从键(如键 == 0 的列表中获取索引)中搜索索引,然后从该索引中我想更改值。
或将值更改为 key == 1
void main() {
var listAnswers = [];
var keyPair = {
'Key': 0,
'value': false,
};
listAnswers.add(keyPair);
keyPair = {
'Key': 1,
'value': 1,
};
listAnswers.add(keyPair);
keyPair = {
'Key': 2,
'value': DateTime.now(),
};
listAnswers.add(keyPair);
print(listAnswers);
var index = listAnswers.getIndex('key', 0)
// got the index 1 (where key = 0, and value = false)
listAnswers[i].value = true; // then I want to do something like this.
}
【问题讨论】:
标签: list flutter dictionary dart