【发布时间】:2021-02-25 15:56:07
【问题描述】:
如何通过特定键合并两个 List
例如:
List
List<Map<String, dynamic>> Wallet = [
{
"id": 1,
"value": 153030
},
{
"id": 2,
"value": 817831
},
{
"id": 3,
"value": 25
},
{
"id": 4,
"value": 660
},
{
"id": 5,
"value": 132
},
{
"id": 7,
"value": 145
}
];
List<Map<String, dynamic>> Currencies = [
{
"id": 1,
"name": "coin",
"desc": "Dummytext.",
"order": 101,
"icon": "https://icon1.png"
},
{
"id": 2,
"name": "karma",
"desc": "Dummytext.",
"order": 102,
"icon": "https://icon2.png"
},
{
"id": 3,
"name": "laurel",
"desc": "Dummytext.",
"order": 104,
"icon": "https://icon3.png"
},
{
"id": 4,
"name": "diamonds",
"desc": "Dummytext.",
"order": 100,
"icon": "https://icon4.png"
},
{
"id": 5,
"name": "tears",
"desc": "Dummytext.",
"order": 402,
"icon": "https://icon5.png"
},
{
"id": 6,
"name": "shard",
"desc": "Dummytext.",
"order": 409,
"icon": "https://icon6.png"
},
{
"id": 7,
"name": "relict",
"desc": "Dummytext.",
"order": 400,
"icon": "https://icon7.png"
},
{
"id": 9,
"name": "seal",
"desc": "Dummytext.",
"order": 403,
"icon": "https://icon9.png"
},
{
"id": 10,
"name": "silver",
"desc": "Dummytext.",
"order": 405,
"icon": "https://icon10.png"
}
];
合并后的列表我要找的操作后
List<Map<String, dynamic>> ExtendedWallet = [
{
"id": 1,
"value": 153030,
"name": "coin",
"desc": "Dummytext.",
"order": 101,
"icon": "https://icon1.png"
},
{
"id": 2,
"value": 817831,
"name": "karma",
"desc": "Dummytext.",
"order": 102,
"icon": "https://icon2.png"
},
{
"id": 3,
"value": 25,
"name": "laurel",
"desc": "Dummytext.",
"order": 104,
"icon": "https://icon3.png"
},
{
"id": 4,
"value": 660,
"name": "diamonds",
"desc": "Dummytext.",
"order": 100,
"icon": "https://icon4.png"
},
{
"id": 5,
"value": 132,
"name": "tears",
"desc": "Dummytext.",
"order": 402,
"icon": "https://icon5.png"
},
{
"id": 7,
"value": 145,
"name": "relict",
"desc": "Dummytext.",
"order": 400,
"icon": "https://icon7.png"
}
];
请注意,“id”在 Wallet 中 not 的 Currencies 地图将不会被使用,将被跳过。
希望你们能得到我的意见,并能帮助我解决这个问题!
【问题讨论】:
标签: list flutter dictionary dart merge