Delete selected keys from Dart Map
问题 What is the Dart idiomatic way to remove selected keys from a Map? Below I'm using a temporary emptyList to hold String keys. Is there a cleaner way? List<String> emptyList = new List<String>(); _objTable.keys.forEach((String name) { if (_objTable[name].indices.isEmpty) { emptyList.add(name); print("OBJ: deleting empty object=$name loaded from url=$url"); } }); emptyList.forEach((String name) => _objTable.remove(name)); 回答1: You can do something like this : _objTable.keys .where((k) =>