onRemoved method

  1. @override
  2. @mustCallSuper
void onRemoved()
inherited

When a component has been removed from the Core Context, we clean up any dangling references left on the parent and on any other dependent component. It's important for specialization of Component to respond to override onDependencyRemoved and clean up any further stored references to that component (for example the target of a Constraint).

Implementation

@override
@mustCallSuper
void onRemoved() {
  super.onRemoved();
  for (final parentDep in _dependsOn) {
    parentDep.dependents.remove(this);
  }
  _dependsOn.clear();

  for (final dependent in dependents) {
    dependent.onDependencyRemoved(this);
  }
  dependents.clear();

  // silently clear from the parent in order to not cause any further undo
  // stack changes
  if (parent != null) {
    parent!.children.remove(this);
    parent!.childRemoved(this);
  }

  // The artboard containing this component will need its dependencies
  // re-sorted.

  if (artboard != null) {
    context.markDependencyOrderDirty();
    changeArtboard(null);
  }
}