diff --git a/packages/flutter/lib/widgets/block_viewport.dart b/packages/flutter/lib/widgets/block_viewport.dart index aef934a532..1ce2c3d95f 100644 --- a/packages/flutter/lib/widgets/block_viewport.dart +++ b/packages/flutter/lib/widgets/block_viewport.dart @@ -117,14 +117,6 @@ class BlockViewport extends RenderObjectWrapper { 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() { renderObject.callback = layout; super.didMount(); diff --git a/packages/flutter/lib/widgets/framework.dart b/packages/flutter/lib/widgets/framework.dart index 4a73b942ef..198c6f37c0 100644 --- a/packages/flutter/lib/widgets/framework.dart +++ b/packages/flutter/lib/widgets/framework.dart @@ -295,21 +295,11 @@ abstract class Widget { } void remove() { + walkChildren((Widget child) => child.remove()); _renderObject = 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(); // 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 assert(oldNode.mounted); oldNode.detachRenderObject(); - removeChild(oldNode); + oldNode.remove(); assert(!oldNode.mounted); return null; } @@ -348,7 +338,7 @@ abstract class Widget { } else { assert(oldNode.mounted); oldNode.detachRenderObject(); - removeChild(oldNode); + oldNode.remove(); oldNode = null; } } @@ -441,12 +431,6 @@ abstract class TagNode extends Widget { child.updateSlot(newSlot); } - void remove() { - if (child != null) - removeChild(child); - super.remove(); - } - void detachRenderObject() { if (child != null) child.detachRenderObject(); @@ -618,9 +602,8 @@ abstract class Component extends Widget { void remove() { assert(_built != null); assert(renderObject != null); - removeChild(_built); - _built = null; super.remove(); + _built = null; } void detachRenderObject() { @@ -1020,12 +1003,6 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper { renderObject.child = null; 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 { @@ -1062,15 +1039,6 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper { 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() { var idSet = new HashSet(); for (var child in children) { diff --git a/packages/flutter/lib/widgets/scaffold.dart b/packages/flutter/lib/widgets/scaffold.dart index 050a5dff5d..c87c79c1c4 100644 --- a/packages/flutter/lib/widgets/scaffold.dart +++ b/packages/flutter/lib/widgets/scaffold.dart @@ -219,11 +219,6 @@ class Scaffold extends RenderObjectWrapper { 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) { super.syncRenderObject(old); for (ScaffoldSlots slot in ScaffoldSlots.values) {