Dart macros are not coming

1 minute read

The news just dropped that Dart will not get macros/metaprogramming/data classes support anytime soon. The related ticket to improve data class support in Dart received almost 1400 upvotes, which I think shows how important that issue has been for us Dart and Flutter developers. We’ve been impatiently waiting for macros for a while now. It was supposed to be a solution to all data handling and serialization problems. Now the work has been stopped and the explanation given by Vijay seems like it’s actually a good call.

Medium post announcing: Dart macros are not coming anytime soon...

Last year a first preview of macros support arrived and we all got quite excited. For me the most fun were improvements to equatable and json serialization. It looked promising and since then we were basically waiting for more updates.

The explanation we are given in the post paints a picture of much more complicated situation than might be expected. Seems like the rippling effect of the macros feedback loop would degrade the overall developer experience by slowing down the analysis and compilation times significantly — in a way that the Dart team could not find solutions for. I am known to complain about slow analyzer a lot (mostly due to big monorepo projects using hundreds of barrel files etc.) and even with recent pub workspace update it’s not really the smoothest ride. Hence, for me if the macros would make my work slower, I don’t think I’d be the most avid user of them.

Seems like the common code generation with build_runner is going to stay with us for much longer. I hope that at least some form of more convenient serialization is going to arrive — you can check recent RFP from Kilian Schulte (discussion post) that tries to solve this in a more generalized way than just focusing on json serialization only.

In the meantime stay safe!

Updated: