Fix contradictory advice in "detach" docs; cut redundancy in "attach"#130688
Fix contradictory advice in "detach" docs; cut redundancy in "attach"#130688auto-submit[bot] merged 3 commits intoflutter:masterfrom
Conversation
Fixes flutter#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 flutter#76021), because that PR shows the old version must have been easy to overlook.
|
Would it make sense to phrase it something like "Implementations in subclasses should attach their children after calling the superclass method" (as opposed to "must start with calling the superclass method")? (Maybe with better phrasing, that's not my best work!) The point being to avoid implying that doing unrelated work before calling the superclass is a problem. |
|
Yeah. Perhaps like this? /// 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)`. /// Subclasses with children should override this method to
/// [detach] all their children after calling the inherited
/// method, as in `super.detach()`.That is:
This version (unlike what's in main) doesn't mention that implementations even in subclasses without children should call the superclass method. But |
|
SGTM. |
|
Cool. Pushed a revision with that text. |
|
auto label is removed for flutter/flutter, pr: 130688, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…flutter#130688) Fixes flutter#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 flutter#76021), because that PR shows the old version must have been easy to overlook.
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.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.