macro_kit
0.8.2, released 3 months ago by rebaz.xyz
A development-time macro system for instant code generation without build_runner.
What it does
Macro Kit provides an analyzer-plugin-based macro system that generates code instantly on save in under 100ms. It includes built-in macros for data classes, compile-time computation, asset paths, shader reloading, and embedding files.
AI-written summary of version 0.8.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want fast code generation without the overhead of build_runner
- You need to generate data classes, asset paths, or embed files directly in Dart
Skip it when
- You rely strictly on standard official Dart macros which have different APIs
- You are targeting environments where analyzer plugins cannot be set up
Strengths
- Generates code in under 100ms after initial run
- Eliminates slow build processes and build_runner conflicts
- Allows real-time debugging of macros inside your app
Weaknesses
- Macros are currently limited to classes, top-level functions, records, and top-level variables
- Requires manual setup of an analysis_options plugin and a macro_context file
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 18
Requires activating the global tool, configuring plugins in analysis_options.yaml, and creating a macro_context.dart file.
import 'package:macro_kit/macro_kit.dart';
@dataClassMacro
class User with UserData {
const User({required this.id, required this.name});
final int id;
final String name;
}Alternatives
Packages that do the same job and could replace macro_kit.
- build
If you prefer the standard build system infrastructure over custom development-time macro servers.
87Compare - build_runner
If you need a battle-tested and widely adopted code generation framework across the Dart ecosystem.
93Compare - freezed_annotation
If you want mature union types and immutable data classes via build_runner.
78Compare
Works with
Packages commonly used together with macro_kit: ones it builds on, ones built on it, and its own family.
- analyzermacro_kit depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlmacro_kit depends on itA Dart library for parsing YAML documents into Dart data structures.
- dart_stylemacro_kit depends on itProvides an API and CLI to format Dart source code automatically.
- shelfmacro_kit depends on itComposable web server middleware for Dart
- watchermacro_kit depends on itMonitors file system changes and notifies when files are added, removed, or modified.
- shelf_web_socketmacro_kit depends on itShelf handler that upgrades HTTP to WebSocket and provides a WebSocketChannel per connection.
- loggingmacro_kit depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- web_socket_channelmacro_kit depends on itCross‑platform WebSocket channel wrapper for Dart