macro_kit library

Classes

AssetMacroInfo
Configuration for asset-based macro generation.
AssetPathConfig
Configuration for the AssetPath macro that controls how asset path fields are generated.
AssetPathMacro
A macro generator that automatically creates type-safe asset path constants from a directory structure.
AssetState
State information about the asset directory when processing asset-related macros.
AutoRebuildResult
Result of an automatic macro rebuild operation.
ComputeMacro
A macro that executes a compute function at compile time and generates a const/final/var variable with the result.
ComputeModifier
User-friendly modifier for ComputeMacro.
DartCode
A wrapper that lets compute macros return raw Dart source code instead of a runtime value.
DataClassMacro
DataClassMacro generates common data-class boilerplate such as fromJson, toJson, copyWith, equality, toString, and (in the future) constructor implementations.
DeepCollectionEquality
Deep equality on collections.
EmbedDirectory
Represents an embedded directory that can list its contents.
EmbedFile
Represents an embedded file with methods to read its contents.
EmbedFileEntity
Base interface for embedded file system entities (files and directories).
EmbedMacro
A macro that embeds asset files directly into Dart code as byte arrays.
EmbedMacroConfig
Configuration for the Embed macro.
EmbedRegistry
Abstract registry that manages embedded file data and caching.
EnumValue
Represents a default enum value or multiple enum values for handling unknown cases.
Identifiable<T>
JsonKey
An annotation used to specify how a field is serialized.
Macro Get started Installation Models Data Class Macro Compute Macro Asset Path Macro Embed Macro Global Configuration Write New Macro Capability
Macro used to attach metadata to a Dart declaration.
MacroAssetDeclaration
Represents an asset file change event for macro processing.
MacroCapability
A MacroCapability describes which elements of a class (constructors, fields, methods, metadata, and subtypes) should be collected and made available to the macro during generation.
MacroClassConstructor
MacroClassDeclaration
Represents a class declaration with its metadata, members, and macro configurations.
MacroConfig
Represents the configuration for a macro applied to a specific declaration.
MacroFunctionDeclaration
Represents a top level function declaration with its metadata, and macro configurations.
MacroGenerator
Base class for implementing macro code generation.
MacroGlobalConfig
A base class for macro global configuration.
MacroKey
Represents a single metadata annotation applied to a declaration, such as @JsonKey or any custom macro configuration.
MacroMethod
Represents a method declaration
MacroProperty
Represents a property or type declaration with comprehensive metadata.
MacroRecordDeclaration
Represents a record declaration with its metadata, members, and macro configurations.
MacroState
Provides contextual information and utilities for macro code generation.
MacroVariableDeclaration
Represents a variable declaration with its macro configuration.
PackageInfo
Provides package identification for connecting macros to the Macro server.
ShaderBundleManifest
A parsed *.shaderbundle.json manifest with its shader source paths already resolved to absolute paths.
ShaderReloaderConfig
Configuration for the shader reload macro.
ShaderReloaderMacro
An asset macro that watches shader sources and rebuilds Flutter GPU shader bundles.

Enums

AssetChangeType
FieldRename
Defines naming conventions for transforming field names.
GeneratedType
The type of code this macro generates.
TargetType
The target type that the macro has been applied to
TypeInfo

Extension Types

MacroModifier
Option
A type-safe wrapper for representing optional values in copyWith methods.

Constants

computeMacro → const Macro
Shorthand annotation for the compute macro (default: const).
computeMacroCapability → const MacroCapability
Default capability for the compute macro.
computeMacroCombined → const Macro
Shorthand annotation for the compute macro with code combining.
dataClassMacro → const Macro
DataClassMacro generates common data-class boilerplate such as fromJson, toJson, copyWith, equality, toString, and (in the future) constructor implementations.
dataClassMacroCombined → const Macro
see dataClassMacro
macroBuildOnce → const List<int>
Sentinel dependency list that marks a compute macro to build only once.

Properties

macroDartRunnerCommand List<String>
Default command to run the macro runner using Dart VM
no setter
macroFlutterRunnerCommand List<String>
Command used to run the macro runner via the Flutter test runner.
no setter
onMacroFilesGenerated Stream<List<String>>
Broadcasts the absolute paths of files generated by asset macros (e.g. compiled shader bundles, embedded assets, generated code files).
no setter

Functions

buildGeneratedFileInfoFor({required String forFilePath, required String? inContextPath, required String remapGeneratedFileTo, bool generatePartFromSource = false}) GenPartDirectiveInfo
Builds the generated file path and the relative part directive path, remapping the output base directory using remapGeneratedFileTo when provided.
compute<T>(FutureOr<T> fn(), {String encode(T value)?, String decode(String value)?, List<Object>? deps}) FutureOr<T> Function()
Marker function for compile-time computation.
keepMacroRunner() Future<void>
Keeps the macro runner process alive when launched via test runners
parentPathOf(String path) String
processComputedResult<T>(T raw, [String enc(T)?, String dec(String value)?]) Object?
Processes a raw compute result before transport across isolate/process boundaries.
runMacro({required PackageInfo package, required bool autoRunMacro, required Map<String, MacroInitFunction> macros, Map<String, List<AssetMacroInfo>> assetMacros = const {}, Level logLevel = Level.INFO, void log(Object? value)?, String? serverAddress, bool autoReconnect = true, Duration generateTimeout = const Duration(seconds: 30), bool enabled = _kDebugMode}) Future<int?>
Sets up and manages macro execution with optional asset monitoring.
waitUntilRebuildCompleted() Future<AutoRebuildResult>
Waits until the macro code regeneration process completes

Typedefs

GenPartDirectiveInfo = ({String genFilePath, String partFromGenerated, String partFromSource})
IntType = int
MacroGlobalConfigParser = MacroGlobalConfig? Function(Map<String, dynamic> json)
A function type for parsing global macro configuration from JSON.
MacroInitFunction = MacroGenerator Function(MacroConfig config)