Should have a guide for usage (and implementation) of ".of()"-style functions #4155#64791
Should have a guide for usage (and implementation) of ".of()"-style functions #4155#64791fluttergithubbot merged 1 commit intoflutter:masterfrom fourman-alex:4155_of_guide
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
of correctly.|
@Hixie you seem to be the one to add the |
There was a problem hiding this comment.
"bellow" here should be "below"
There was a problem hiding this comment.
🤦♂️ oh, that's right
There was a problem hiding this comment.
removed the comments entirely as we now have similar text before each snippet
There was a problem hiding this comment.
Added the type annotation but I think we need to explicitly name the inner context differently so that the developers who we target with this documentation will have an easier time seeing how this is a different context
There was a problem hiding this comment.
"In this example, the context used is the one from the Builder, which is a child of the FrogColor widget, so this works:"
There was a problem hiding this comment.
In this example, the context used is the one from the MyOtherPage widget, which is an ancestor of the FrogColor widget, so this does not work:
There was a problem hiding this comment.
oh i also meant to remove "DON'T" (and "DO" above). The writing style for the API docs try to avoid telling people what to do, they just give information and let the reader decide what to do with it.
There was a problem hiding this comment.
for clarity let's put a header like "## The `.of` method convention" or "Implementing `.of` methods" above the paragraph that starts "The convention...", and then a similar header above your new text e.g. "## Calling \.of\ methods" or some such.
|
This is great! My comments are merely minor tweaks. |
|
@Hixie Added some changes based on the review. Please let me know if you see anything else. |
|
looking good! |
|
@Hixie Removed the DO/DON'Ts and changed "bellow" to "below" |
|
Thanks! This is great! |
see #4155
Description
This addresses issue #4155 by adding additional guidance on how to use the
ofmethod, specifically thecontextthat should be used.Because this is an issue usually met by developers new to flutter I added explicit DO and DON'T code snippets on top of the verbal explanation.
Related Issues
Fixes #4155
Tests
Not applicable for changes to documentation.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].