-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Prefer .of to .from #94772
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
Prefer .of to .from #94772
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. 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. |
Why not just |
test-exempt: preparing codebase for future lint (dart-lang/sdk#58359) |
These aren't always lists. |
the List.of() cases are always Iterables though right? And can always be replaced by toList? |
Presumably yes. But I got here from looking at maps |
The implementation of toList is to forward to List.of: https://master-api.flutter.dev/flutter/dart-core/Iterable/toList.html |
fair enough. FWIW in general i feel toList is more idiomatic (and shorter) but I don't have a strong opinion here. |
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
.from uses a typecast.
.of does not.
We should have a lint for this - see dart-lang/sdk#58359
There's not really a good way to test this right now. What we really want is a lint.
For historical context: my understanding is that
from
is more of a Dart 1 thing that was the original go-to andof
was added later to make better use of types.