-
Notifications
You must be signed in to change notification settings - Fork 213
Support shorthand class creation syntax #1002
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
Comments
cc @munificent @lrhn |
I'm unable to find other requests for the same thing (which surprises me, except that I can never find anything using GitHub search). What we are asking for here is a shorter syntax to write a simple class, without having to repeat the field names (or even class name) in a constructor. |
@lrhn perhaps dart-lang/sdk#10551, dart-lang/sdk#10374 |
Is there something similar to inline classes in Dart? |
No, we don't have that currently. The main property of an inline class (corresponding to Haskell |
Thanks @eernstg for the info. Excited for the above feature to be added in Dart. |
Moving this issue to the language repo, it would be a language mechanism. |
Seee #698 – covers your case nicely I think! |
We're tracking this here, closing in favor of that issue (let me know if I've missed something distinct about this request. |
For classes with a single constructor that takes in a few values.
It would be much cleaner and concise to simply allow a "primary constructor":
Duplicating constructor and class declaration seems a little clunky. When we have more fields,
this duplication is further known and wish we could take it a step further to allow:
Less duplication in code will lead to nice details in our widgets for flutter like from this:
to this:
from 17 lines of boilerplate to 8.
The text was updated successfully, but these errors were encountered: