-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add typically used parameter name to the builder used in layout_builder #119877
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
Add typically used parameter name to the builder used in layout_builder #119877
Conversation
when you're using ide like intelliJ, if function parameter is omitted, code completion suggests using paramter name like c0, c1...
|
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 (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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
| /// | ||
| /// The builder must not return null. | ||
| final Widget Function(BuildContext, ConstraintType) builder; | ||
| final Widget Function(BuildContext context, ConstraintType constraints) builder; |
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.
Actually, per our style guide this should actually be using a typedef. Something like:
| final Widget Function(BuildContext context, ConstraintType constraints) builder; | |
| final ConstrainedLayoutWidgetBuilder<ConstraintType> builder; |
with
/// The signature of the [ConstrainedLayoutBuilder] builder function.
typedef ConstrainedLayoutWidgetBuilder<ConstraintType extends Constraints> = Widget Function(BuildContext context, ConstraintType constraints);Since you're in here, would you mind cleaning this up?
|
Since this affects the IDE experience, it could be worthwhile to have a lint reminding us to always add function parameter names (cc @pq). @bebe0612 Would you mind filing a request for that at https://github.com/dart-lang/linter/issues/new/choose ? |
|
test-exempt: code style but many bonus points would be applied if you could find a way to detect this kind of problem in the code (e.g. via a lint). |
|
Let's submit this as-is for now, I'll follow up with a PR to fix my (unrelated) nit. |
|
auto label is removed for flutter/flutter, pr: 119877, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead. |
|
auto label is removed for flutter/flutter, pr: 119877, due to Validations Fail. |
Piinks
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!
|
Filed lint proposal: dart-lang/sdk#59047 |
## Description Similar to #119877, but with more cases that I could find in `packages/flutter`. Although there is already a [proposal](https://github.com/dart-lang/linter/issues/4102), it is uncertain how long it will take to be implemented. ](https://user-images.githubusercontent.com/72788825/216486897-b56453d2-b309-47ea-885b-b0ec6ed1b648.png)
When you're using ide like intelliJ, if function parameter is omitted, code completion suggests using paramter name like c0, c1... Below is example what i said.
It affects two main usage,
LayoutBuilder,SliverLayoutBuilderand many people are using parameter name below. (coplilot recommended 👍 )Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.