Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 从地图中删除元素_Dart_Flutter - Fatal编程技术网

Dart 从地图中删除元素

Dart 从地图中删除元素,dart,flutter,Dart,Flutter,如何在地图上进行迭代,逐个删除地图上的元素,然后在删除每个元素后调用一个函数 假设我有释放功能 final HashMap<int, bool> _instances = new HashMap<int, bool>(); void release(dynamic instance) { if (_instances[instance.hashCode] != null) { _releaseHashCode(instance.hashCod

如何在地图上进行迭代,逐个删除地图上的元素,然后在删除每个元素后调用一个函数

假设我有释放功能

  final HashMap<int, bool> _instances = new HashMap<int, bool>();

  void release(dynamic instance) {
    if (_instances[instance.hashCode] != null) {
      _releaseHashCode(instance.hashCode);
      _dispatcher.dispatchEvent(PinEvent.release);
    }
  }

  void _releaseHashCode(int hashCode) => _instances.remove(hashCode);
我就是这样做的

  void releaseAll() {
    var tempMap = new HashMap<int, bool>()..addAll(_instances);
    tempMap.forEach((int hashCode, bool value) {
      _releaseHashCode(hashCode);
      _dispatcher.dispatchEvent(PinEvent.release);
    });
    tempMap.clear();
    tempMap = null;
  }
void releaseAll(){
var tempMap=newhashmap()…addAll(_实例);
forEach((int hashCode,bool值){
_释放hashCode(hashCode);
_dispatcher.dispatchEvent(PinEvent.release);
});
tempMap.clear();
tempMap=null;
}
我就是这样做的

  void releaseAll() {
    var tempMap = new HashMap<int, bool>()..addAll(_instances);
    tempMap.forEach((int hashCode, bool value) {
      _releaseHashCode(hashCode);
      _dispatcher.dispatchEvent(PinEvent.release);
    });
    tempMap.clear();
    tempMap = null;
  }
void releaseAll(){
var tempMap=newhashmap()…addAll(_实例);
forEach((int hashCode,bool值){
_释放hashCode(hashCode);
_dispatcher.dispatchEvent(PinEvent.release);
});
tempMap.clear();
tempMap=null;
}
检查removeWhere

final Map<String, dynamic> tempMap = json.decode(jsonValue);
tempMap.removeWhere((String key, dynamic value)=> value==null);
final Map tempMap=json.decode(jsonValue);
tempMap.removeWhere((字符串键,动态值)=>value==null);
检查removeWhere

final Map<String, dynamic> tempMap = json.decode(jsonValue);
tempMap.removeWhere((String key, dynamic value)=> value==null);
final Map tempMap=json.decode(jsonValue);
tempMap.removeWhere((字符串键,动态值)=>value==null);