Dart Macros — Compile-time Code Generation Without build_runner
Dart's macro system lets you generate and transform code at compile time — no build_runner , no .g.dart files. Here's what it means in practice.
The Problem With build_runner
// Before macros: json_serializable workflow // 1. Add dependencies to pubspec.yaml // 2. Annotate with @JsonSerializable() // 3. Run: dart run build_runner build (slow) // 4. Commit the generated *.g.dart file // 5. Remember to re-run when you change the class 😩
@JsonSerializable () class Task { final String id ; final String title ; Task ({ required this . id , required this . title }); factory Task .…