---
title: "Discussion on \"From Annotations to Generation: Building Your First Dart Code Generator\" | Hashnode"
description: "Discussion on \"From Annotations to Generation: Building Your First Dart Code Generator\". Discover why Flutter needs code generators and how to build your own. Complete guide with examples, tips, and best practices."
url: "https://hashnode.com/posts/from-annotations-to-generation-building-your-first-dart-code-generator/67767098ddde191c5d6727e3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [From Annotations to Generation: Building Your First Dart Code Generator](https://dinkomarinac.dev/from-annotations-to-generation-building-your-first-dart-code-generator?utm_source=hashnode&utm_medium=feed)

Discover why Flutter needs code generators and how to build your own. Complete guide with examples, tips, and best practices.

Jan 2, 2025 · 10 min read · dinkomarinac.dev  
Read the article

-   [#dart](https://hashnode.com/tag/dart)
-   [#flutter](https://hashnode.com/tag/flutter)
-   [#codegeneration](https://hashnode.com/tag/codegeneration)

## Written by

[Dinko Marinac](https://hashnode.com/@dinko7)

@dinko7 · Zagreb, Croatia

  
[View profile](https://hashnode.com/@dinko7)

Flutter and Dart Developer and Consultant.

Mobile app developer and consultant. CEO @ MOBILAPP Solutions. Passionate about the Dart &amp; Flutter ecosystem.

## Responses 1

Markdown supported · ⌘↵ to post

[Taha Teber](https://hashnode.com/@tahateber)

[Jan 5, 2025](https://hashnode.com/posts/from-annotations-to-generation-building-your-first-dart-code-generator/67767098ddde191c5d6727e3/comment/677a5650696a31f0d05c19e8)

Very informative, Thank you

My opinion regarding code generation is macros will replace it, I am myself anti-code gen in Flutter, a lot of .g files, It always seems to make things easier at first, and then when there are any problems you're staring at a black box, and I don't need to read the black box.

[Dinko Marinac](https://hashnode.com/@dinko7)

[Jan 5, 2025](https://hashnode.com/posts/from-annotations-to-generation-building-your-first-dart-code-generator/67767098ddde191c5d6727e3/comment/677a5650696a31f0d05c19e8#reply-677a6ed7e21a4067d16ccf56)

Hi Taha, thanks for sharing your opinion. Macros will never fully replace build\_runner because they generate Dart code only, so in the case of Pidgeon or any use case where your output is not a Dart file, macros will not be useful.

Also, they are still experimental, but judging only by the preview macro JsonCodable, the way augment class works, also means that they will not work for generating standalone Dart files.

Will it replace .g.dart and .extension.dart? Yes. But that's about the extent of it.
