Unverified Commit f0039119 authored by Greg Price's avatar Greg Price Committed by GitHub

Fix contradictory advice in "detach" docs; cut redundancy in "attach" (#130688)

Fixes #115525.

On [AbstractNode.detach] and its two progeny [RenderNode.detach]
and [Layer.detach], the docs said both to call the inherited method
before detaching children, and to end by doing so.  The former
advice is what's enforced by an assertion in the base implementation,
so cut out the other.

The corresponding [attach] methods redundantly said twice to
call the inherited method first, so cut the redundancy.
Leave in place the version more recently added (in #76021), because
that PR shows the old version must have been easy to overlook.
parent ef43463c
......@@ -92,12 +92,9 @@ class AbstractNode {
/// Typically called only from the [parent]'s [attach] method, and by the
/// [owner] to mark the root of a tree as attached.
///
/// Subclasses with children should override this method to first call their
/// inherited [attach] method, and then [attach] all their children to the
/// same [owner].
///
/// Implementations of this method should start with a call to the inherited
/// method, as in `super.attach(owner)`.
/// Subclasses with children should override this method to
/// [attach] all their children to the same [owner]
/// after calling the inherited method, as in `super.attach(owner)`.
@mustCallSuper
void attach(covariant Object owner) {
assert(_owner == null);
......@@ -109,11 +106,9 @@ class AbstractNode {
/// Typically called only from the [parent]'s [detach], and by the [owner] to
/// mark the root of a tree as detached.
///
/// Subclasses with children should override this method to first call their
/// inherited [detach] method, and then [detach] all their children.
///
/// Implementations of this method should end with a call to the inherited
/// method, as in `super.detach()`.
/// Subclasses with children should override this method to
/// [detach] all their children after calling the inherited method,
/// as in `super.detach()`.
@mustCallSuper
void detach() {
assert(_owner != null);
......
......@@ -518,12 +518,9 @@ abstract class Layer with DiagnosticableTreeMixin {
/// Typically called only from the [parent]'s [attach] method, and by the
/// [owner] to mark the root of a tree as attached.
///
/// Subclasses with children should override this method to first call their
/// inherited [attach] method, and then [attach] all their children to the
/// same [owner].
///
/// Implementations of this method should start with a call to the inherited
/// method, as in `super.attach(owner)`.
/// Subclasses with children should override this method to
/// [attach] all their children to the same [owner]
/// after calling the inherited method, as in `super.attach(owner)`.
@mustCallSuper
void attach(covariant Object owner) {
assert(_owner == null);
......@@ -535,11 +532,9 @@ abstract class Layer with DiagnosticableTreeMixin {
/// Typically called only from the [parent]'s [detach], and by the [owner] to
/// mark the root of a tree as detached.
///
/// Subclasses with children should override this method to first call their
/// inherited [detach] method, and then [detach] all their children.
///
/// Implementations of this method should end with a call to the inherited
/// method, as in `super.detach()`.
/// Subclasses with children should override this method to
/// [detach] all their children after calling the inherited method,
/// as in `super.detach()`.
@mustCallSuper
void detach() {
assert(_owner != null);
......
......@@ -2074,12 +2074,9 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
/// Typically called only from the [parent]'s [attach] method, and by the
/// [owner] to mark the root of a tree as attached.
///
/// Subclasses with children should override this method to first call their
/// inherited [attach] method, and then [attach] all their children to the
/// same [owner].
///
/// Implementations of this method should start with a call to the inherited
/// method, as in `super.attach(owner)`.
/// Subclasses with children should override this method to
/// [attach] all their children to the same [owner]
/// after calling the inherited method, as in `super.attach(owner)`.
@mustCallSuper
void attach(PipelineOwner owner) {
assert(!_debugDisposed);
......@@ -2116,11 +2113,9 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
/// Typically called only from the [parent]'s [detach], and by the [owner] to
/// mark the root of a tree as detached.
///
/// Subclasses with children should override this method to first call their
/// inherited [detach] method, and then [detach] all their children.
///
/// Implementations of this method should end with a call to the inherited
/// method, as in `super.detach()`.
/// Subclasses with children should override this method to
/// [detach] all their children after calling the inherited method,
/// as in `super.detach()`.
@mustCallSuper
void detach() {
assert(_owner != null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment