Remove Widget.removeChild
This function just calls remove(). Also, have Widget do the recursive remove walk by calling walkChildren.
This commit is contained in:
parent
62e67957c9
commit
2db1f59c74
@ -117,14 +117,6 @@ class BlockViewport extends RenderObjectWrapper {
|
|||||||
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
|
||||||
for (Widget child in layoutState._childrenByKey.values) {
|
|
||||||
assert(child != null);
|
|
||||||
removeChild(child);
|
|
||||||
}
|
|
||||||
super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void didMount() {
|
void didMount() {
|
||||||
renderObject.callback = layout;
|
renderObject.callback = layout;
|
||||||
super.didMount();
|
super.didMount();
|
||||||
|
@ -295,21 +295,11 @@ abstract class Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
void remove() {
|
||||||
|
walkChildren((Widget child) => child.remove());
|
||||||
_renderObject = null;
|
_renderObject = null;
|
||||||
setParent(null);
|
setParent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeChild(Widget node) {
|
|
||||||
// Call this when we no longer have a child equivalent to node.
|
|
||||||
// For example, when our child has changed type, or has been set to null.
|
|
||||||
// Do not call this when our child has been replaced by an equivalent but
|
|
||||||
// newer instance that will sync() with the old one, since in that case
|
|
||||||
// the subtree starting from the old node, as well as the render tree that
|
|
||||||
// belonged to the old node, continue to live on in the replacement node.
|
|
||||||
node.remove();
|
|
||||||
assert(node.parent == null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void detachRenderObject();
|
void detachRenderObject();
|
||||||
|
|
||||||
// Returns the child which should be retained as the child of this node.
|
// Returns the child which should be retained as the child of this node.
|
||||||
@ -328,7 +318,7 @@ abstract class Widget {
|
|||||||
// the child in this slot has gone away
|
// the child in this slot has gone away
|
||||||
assert(oldNode.mounted);
|
assert(oldNode.mounted);
|
||||||
oldNode.detachRenderObject();
|
oldNode.detachRenderObject();
|
||||||
removeChild(oldNode);
|
oldNode.remove();
|
||||||
assert(!oldNode.mounted);
|
assert(!oldNode.mounted);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -348,7 +338,7 @@ abstract class Widget {
|
|||||||
} else {
|
} else {
|
||||||
assert(oldNode.mounted);
|
assert(oldNode.mounted);
|
||||||
oldNode.detachRenderObject();
|
oldNode.detachRenderObject();
|
||||||
removeChild(oldNode);
|
oldNode.remove();
|
||||||
oldNode = null;
|
oldNode = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,12 +431,6 @@ abstract class TagNode extends Widget {
|
|||||||
child.updateSlot(newSlot);
|
child.updateSlot(newSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
|
||||||
if (child != null)
|
|
||||||
removeChild(child);
|
|
||||||
super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void detachRenderObject() {
|
void detachRenderObject() {
|
||||||
if (child != null)
|
if (child != null)
|
||||||
child.detachRenderObject();
|
child.detachRenderObject();
|
||||||
@ -618,9 +602,8 @@ abstract class Component extends Widget {
|
|||||||
void remove() {
|
void remove() {
|
||||||
assert(_built != null);
|
assert(_built != null);
|
||||||
assert(renderObject != null);
|
assert(renderObject != null);
|
||||||
removeChild(_built);
|
|
||||||
_built = null;
|
|
||||||
super.remove();
|
super.remove();
|
||||||
|
_built = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void detachRenderObject() {
|
void detachRenderObject() {
|
||||||
@ -1020,12 +1003,6 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
|
|||||||
renderObject.child = null;
|
renderObject.child = null;
|
||||||
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
|
||||||
if (child != null)
|
|
||||||
removeChild(child);
|
|
||||||
super.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
|
abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
|
||||||
@ -1062,15 +1039,6 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
|
|||||||
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
|
||||||
assert(children != null);
|
|
||||||
for (var child in children) {
|
|
||||||
assert(child != null);
|
|
||||||
removeChild(child);
|
|
||||||
}
|
|
||||||
super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _debugHasDuplicateIds() {
|
bool _debugHasDuplicateIds() {
|
||||||
var idSet = new HashSet<Key>();
|
var idSet = new HashSet<Key>();
|
||||||
for (var child in children) {
|
for (var child in children) {
|
||||||
|
@ -219,11 +219,6 @@ class Scaffold extends RenderObjectWrapper {
|
|||||||
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
|
||||||
walkChildren((Widget child) => removeChild(child));
|
|
||||||
super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void syncRenderObject(Widget old) {
|
void syncRenderObject(Widget old) {
|
||||||
super.syncRenderObject(old);
|
super.syncRenderObject(old);
|
||||||
for (ScaffoldSlots slot in ScaffoldSlots.values) {
|
for (ScaffoldSlots slot in ScaffoldSlots.values) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user