adoptChild method Null safety
- RestorationBucket child
Adopts the provided child
bucket.
The child
will be dropped from its old parent, if it had one.
The child
is stored under its restorationId in this bucket. If this
bucket already contains a child bucket under the same id, the owner of
that existing bucket must give it up (e.g. by moving the child bucket to a
different parent or by disposing it) before the end of the current frame.
Otherwise an exception indicating the illegal use of duplicated
restoration IDs will trigger in debug mode.
No-op if the provided bucket is already a child of this bucket.
Implementation
void adoptChild(RestorationBucket child) {
assert(_debugAssertNotDisposed());
assert(child != null);
if (child._parent != this) {
child._parent?._removeChildData(child);
child._parent = this;
_addChildData(child);
if (child._manager != _manager) {
_recursivelyUpdateManager(child);
}
}
assert(child._parent == this);
assert(child._manager == _manager);
}