Skip to content

Should have a guide for usage (and implementation) of ".of()"-style functions #4155#64791

Merged
fluttergithubbot merged 1 commit intoflutter:masterfrom
fourman-alex:4155_of_guide
Sep 8, 2020
Merged

Should have a guide for usage (and implementation) of ".of()"-style functions #4155#64791
fluttergithubbot merged 1 commit intoflutter:masterfrom
fourman-alex:4155_of_guide

Conversation

@fourman-alex
Copy link
Contributor

@fourman-alex fourman-alex commented Aug 28, 2020

see #4155

Description

This addresses issue #4155 by adding additional guidance on how to use the of method, specifically the context that 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.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

@flutter-dashboard
Copy link

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.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 28, 2020
@fourman-alex fourman-alex changed the title adds additional guidance on how to use of correctly. Should have a guide for usage (and implementation) of ".of()"-style functions #4155 Aug 28, 2020
@fourman-alex
Copy link
Contributor Author

@Hixie you seem to be the one to add the of documentation here in the first place. Can you give the change a look or point me to someone who can?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"bellow" here should be "below"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ oh, that's right

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the comments entirely as we now have similar text before each snippet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuildContext context

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"In this example, the context used is the one from the Builder, which is a child of the FrogColor widget, so this works:"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Hixie
Copy link
Contributor

Hixie commented Aug 31, 2020

This is great! My comments are merely minor tweaks.

@fourman-alex
Copy link
Contributor Author

@Hixie Added some changes based on the review. Please let me know if you see anything else.

@Hixie
Copy link
Contributor

Hixie commented Sep 3, 2020

looking good!

@fourman-alex
Copy link
Contributor Author

@Hixie Removed the DO/DON'Ts and changed "bellow" to "below"

Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hixie
Copy link
Contributor

Hixie commented Sep 8, 2020

Thanks! This is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should have a guide for usage (and implementation) of ".of()"-style functions

4 participants