Lesser known classes and functions from the Dart core libraries

Thanks for the link, @Hari_07!

Another cool functionality from the Dart SDK that I didn’t know about until recently is the FutureRecord2 extension and its kin.

It lets you do parallel awaits more easily and readably than Future.wait() or [...].wait. Because it works on records. So:

var (text, image) = await (fetchText(), fetchImage()).wait;

Using record instead of iterable means that the types of text and image are correctly inferred, whatever they are.

24 Likes