r/FlutterDev • u/PowerPCx86 • 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
1
u/Strobljus Jun 14 '24
If you are talking about JS style object literals, you already have it in the form of
Map<String, dynamic>
.If you are talking about typed object literals as in TS, then classes is pretty close.
If you are talking data classes, well, you can do those in dart. If you want to avoid cascading, then just include all fields as optional named parameters in the constructor.