r/FlutterDev • u/SaltTM • May 08 '19
Dart Announcing Dart 2.3: Optimized for building user interfaces
https://medium.com/dartlang/announcing-dart-2-3-optimized-for-building-user-interfaces-e84919ca1dff7
u/nirataro May 09 '19
I hope they work on data class for us redux people
4
u/puglife420blazeit May 09 '19
This would be killer! Along with data class, give us the copy method. Having to roll your own is painful if you’re dealing with a lot of objects. Even if they didn’t have the data class, just having a copy method for any po...do? would be a time saver.
Also the when block. Object/array destructuring, data class and/or copy, and the when block and I’d finally be ok with Dart.
3
u/nirataro May 09 '19
Seriously. This is 2019. Doing copy method by hand is so lame.
It's time to tag https://www.reddit.com/user/munificent again.
11
u/munificent May 09 '19
/me appears in a puff of smoke!
So, my personal feeling is, yes, I also want pattern matching and destructuring. As well as tuples and some kind of data class / value type. They all kind of hang together because you want to be able to destructure data classes too, and, if you're doing to do destructuring assignment, you may as well also to refutable destructuring and that's pattern matching.
Previously, the entire Dart team had its hands full moving to Dart 2.0. Dramatically changing a language's static type system after the language is in the wild is no easy feat. We had to migrate literally millions of lines of code, migrate hundreds of thousands of lines of language tests, build new static analysis, all sorts of stuff.
But now that that work is done, we can finally start to leverage it by building features on top of the new type system. Right now, we're working on sound non-nullable types, and extension methods (really extension members since you can do getters/setters/operators/etc.). The latter would have been impossible without the new type system.
My hope is that once those are done, we will be close to where we want to be on the "static type" side of the language. Then one of the areas I hope we can explore is around destructuring/tuples/pattern-matching. There are other areas that come up a lot too, though: concurrency, better modularity, static metaprogramming. So who knows what will rise to the top.
I will say that when I was talking to people at IO, data classes came up very often, right behind non-nullable types and extension methods.
2
1
u/puglife420blazeit May 09 '19
I mean, if you really want to, you can use https://pub.dev/packages/dson_core, and then do a spread on the map, then back to your class. Hacky shit like this should have to be done though.
I know javascript/typescript has the dataclass libary https://github.com/alexeyraspopov/dataclass.
I wonder if it'd be worth trying to port over to dart.
2
u/nirataro May 09 '19
For library solution, this is the best https://github.com/google/built_value.dart.
It uses code generation and stuff so your code base is a bit ugly.
10
u/puglife420blazeit May 09 '19
One thing I’d like to see from javascript is destructuring arrays.
const blah = [2, 6, 8];
const [a, b, c] = blah;
Really good for creating custom hooks with Flutter hooks.
I have a ton of reusable animation hooks that I use in my React Native projects. It’d be nice to use them in Flutter.