Skip to content
pubscout

macro_kit

0.8.2, released 3 months ago by rebaz.xyz

A development-time macro system for instant code generation without build_runner.

$ flutter pub add macro_kit
Source repository

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.

  • build_runner

    If you need a battle-tested and widely adopted code generation framework across the Dart ecosystem.

  • freezed_annotation

    If you want mature union types and immutable data classes via build_runner.

Works with

Packages commonly used together with macro_kit: ones it builds on, ones built on it, and its own family.