-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix contradictory advice in "detach" docs; cut redundancy in "attach" #130688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
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.