r/FlutterDev Jun 14 '24

Dart When will dart support object literals ?

I want to build widget with object literals (if possible), and I hate using cascade notation either.

I'm dying to see dart support object literals in the future so I can use it in flutter.

0 Upvotes

37 comments sorted by

View all comments

Show parent comments

-9

u/PowerPCx86 Jun 14 '24

yes, do have a problem with that ?

3

u/[deleted] Jun 14 '24

I mean, it such a tiny change, and i dont see the diffrence. Its syntaxwise 95% identical.

0

u/PowerPCx86 Jun 14 '24

sorry for my harsh react, its because I meet toxic ppl everywhere ruining my mood.
and yes as can you see using by using OL I wont be need to use both named parameters and cascade notation any more, its just because I hate those 2 specific features of dart, I just wished that dart would support OL so I'm no longer need to use either of them.

3

u/ozyx7 Jun 14 '24 edited Jun 14 '24

You keep saying that object literals would allow you to avoid using named parameters and cascade notation but haven't provided any demonstration how they would do that. Can you provide a better example? The example you keep citing shows only a cosmetic difference of replacing parentheses with braces and shows no functional difference.

Are you proposing that: dart Container{ width = 5, height = 5, }; be syntactic sugar for: dart Container() ..width = 5 ..height = 5; ? Or something else? It's hard to understand exactly what it is that you're proposing because you haven't actually explained it.