8000 Call .toList() implicitely when converting from Iterable<T> to List<T> · Issue #965 · dart-lang/language · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Call .toList() implicitely when converting from Iterable<T> to List<T> #965

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

Closed
ChristianKleineidam opened this issue May 16, 2020 · 4 comments
Labels
feature Proposed language feature that solves one or more problems

Comments

@ChristianKleineidam
Copy link

My Flutter code is full of:

Column(
	children: listOfMyObjects.map((object) => MyWidget(object)).toList()
)

Frequently, I forget to type the .toList() and while the code compiles I get greated by an error on RunTime.

Similarly to how Flutter code looks cleaner since new is optional, I think it would make the code cleaner to make the call to .toList() optional as well.

@ChristianKleineidam ChristianKleineidam added the feature Proposed language feature that solves one or more problems label May 16, 2020
@mateusfccp
Copy link
Contributor

Instead, I would prefer the compiler to throw an error (instead of getting it in runtime).

@rrousselGit
Copy link
rrousselGit commented May 16, 2020 via email

@Cat-sushi
Copy link

see also #108

@leafpetersen
Copy link
Member

If we were to do something around this, it would be something more general, e.g. the proposal linked in the previous comment. Given that this is already tracked, I'm going to close this out.

Note that the case that you forget to call toList will become an (opt-in) error in the upcoming null safety release, so at least you will get help from the compiler when you forget going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems
Projects
None yet
Development

No branches or pull requests

5 participants
0