[英]Dart/Flutter - How to delete key-value-pairs of element of Map inside a List?
How can I can delete a specific key-value-pair in that type of List<Map<String, dynamic>> for each map.如何为每个地图删除该类型的 List<Map<String, dynamic>> 中的特定键值对。
For example:例如:
List<Map<String, dynamic>> before the operation: List<Map<String, dynamic>> 操作前:
List<Map<String, dynamic>> currencies = [
{
'id': 1,
'name': 'coin',
'desc': 'This is just a blindtext.',
'order': 101,
'icon': 'https://icon1.jpg'
},
{
'id': 2,
'name': 'karma',
'desc': 'This is just a blindtext.',
'order': 102,
'icon': 'https://icon2.jpg'
},
{
'id': 3,
'name': 'laurel',
'desc': 'This is just a blindtext.',
'order': 104,
'icon': 'https://icon3.jpg'
},
];
List<Map<String, dynamic>> after the operation I am searching for: List<Map<String, dynamic>>在我搜索的操作之后:
List<Map<String, dynamic>> currencies = [
{
'id': 1,
'name': 'coin',
'icon': 'https://icon1.jpg'
},
{
'id': 2,
'name': 'karma',
'icon': 'https://icon2.jpg'
},
{
'id': 3,
'name': 'laurel',
'icon': 'https://icon3.jpg'
},
];
So basically, I deleted "unwanted" key-value-pairs.所以基本上,我删除了“不需要的”键值对。 Any suggestions?有什么建议?
Thanks in advance!!提前致谢!!
currencies.forEach((item) => item..remove("order")..remove("desc"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.