在每个子元素(element)之后插入新元素的“最佳”方法是什么。
下面自然会给出并发修改异常
element.children.forEach((Element child){
var new_child = new DivElement();
element.insertBefore(new_child, child);
});发布于 2013-11-19 09:55:18
避免ConcurrentModificationError的最简单方法是在进行修改之前通过调用toList()复制列表。
element.children.toList().forEach((Element child){
var new_child = new DivElement();
element.insertBefore(new_child, child);
});https://stackoverflow.com/questions/20067719
复制相似问题