disposeChildren method

  1. @protected
void disposeChildren()

Disposes and removes all children.

Iterates a snapshot of currently-live children. Dead WeakReferences are skipped and pruned lazily. We must iterate a snapshot because ChildPod.dispose calls back into parent._removeChild(this) and mutates _children from underneath us.

Implementation

@protected
void disposeChildren() {
  final live = <ChildPod<Object, Object>>[];
  for (final ref in _children) {
    final t = ref.target;
    if (t != null) live.add(t);
  }
  for (final child in live) {
    try {
      child.dispose();
    } catch (e) {
      Log.err(e, tags: {#df_pod});
    }
  }
}