zorphy library

Zorphy - Modern code generation for Dart/Flutter

This library provides a complete solution for generating boilerplate code like copyWith, JSON serialization, equality, toString, and more.

Classes

AgentDirective
Typed directive consumed by zuraffa's AgentPlugin.
AgentExclude
Marks an entity or usecase so it never becomes an MCP tool.
AgentInternal
Sugar for @AgentRisk(AgentRiskTier.admin).
AgentParamDirective
Per-parameter metadata within an AgentDirective.
AgentRisk
Declares the risk tier for an agent-exposed entity or usecase.
AgentTool
Override the generated MCP tool identity for an entity or usecase.
AgentToolDirective
Tool identity information within an AgentDirective.
AgentToolParam
Provides a description for a field when it appears as a tool parameter in the MCP inputSchema.
AlwaysMatch<TEntity>
A filter that always evaluates to true.
And<TEntity>
Logical AND combining multiple filters
Contains<TEntity, TValue>
Contains filter (e.g., for strings or lists)
EntityConfig
Configuration for entity creation
EntityCreator
Main orchestrator for creating Zorphy entities
EntityResult
Result of entity creation
EnumConfig
Configuration for enum creation
EnumResult
Result of enum creation
Eq<TEntity, TValue>
Equality filter (e.g., field == value)
Field<TEntity, TValue>
Represents a field in a Zorphy entity TEntity with value type TValue. Used for type-safe query construction and runtime evaluation.
FieldDefinition
Field definition for an entity
Filter<TEntity>
Base class for all filters
Gt<TEntity, TValue>
Greater than filter
Gte<TEntity, TValue>
Greater than or equal filter
Has<TEntity, TElement>
List-contains-element filter (e.g., List
Immutable
Annotation on an immutable class.
InList<TEntity, TValue>
In list filter
JsonConverter<T, S>
Implement this class to provide custom converters for a specific Type.
JsonEnum
Allows configuration of how enum elements are treated as JSON.
JsonKey
An annotation used to specify how a field is serialized.
JsonLiteral
An annotation used to generate a private field containing the contents of a JSON file.
JsonSerializable
An annotation used to specify a class to generate code for.
JsonValue
An annotation used to specify how a enum value is serialized.
List_E<E>
Enhanced List type for Zorphy with additional functionality
Lt<TEntity, TValue>
Less than filter
Lte<TEntity, TValue>
Less than or equal filter
NamingUtils
Utility class for naming conventions
Neq<TEntity, TValue>
Not equal filter (e.g., field != value)
Nested<TEntity, TValue>
Nested object or collection filter
Not<TEntity>
Logical NOT negating a filter
Opt<T>
Optional type wrapper for Zorphy
Or<TEntity>
Logical OR combining multiple filters
Patch<T>
Patch interface for Zorphy code generation
PatchBase<TEntity, TEnum extends Enum>
PluginContext
Context provided to each plugin during the transform pass.
PluginDiagnostic
A single diagnostic produced by a plugin.
PluginRegistry
Registry for ZorphyPlugin instances.
RecordUse
Annotation on a statically resolved member or class whose usages will be recorded.
Required
Annotation on a required named parameter.
Sort<TEntity>
Represents a sort operation on a field
SubtypeResult
Result for subtype generation
UseResult
Annotation on function or property whose value must not be ignored.
Zorphy
Zorphy2
Deprecated alias of Zorphy. Behaves identically since zorphy 2.0; will be removed in a later major release.
ZorphyGenerator
Unified single-pass generator for @Zorphy and @Zorphy2 classes.
ZorphyNamedConstructor
Annotation to declare a named constructor with a custom body on the generated concrete class.
ZorphyPlugin
Abstract contract for a Zorphy code-generation plugin.
ZorphyX

Enums

AgentRiskTier
Agent-centric architecture annotations for zorphy.
FieldRename
Values for the automatic field renaming behavior for JsonSerializable.
MergeMode
Controls how zorphy regenerates output files.
PluginDiagnosticLevel
Severity level for a plugin diagnostic.
ZorphyKind
The semantic kind of an annotated class.
ZorphyPreset
Controls how much code zorphy generates for an annotated class.

Extensions

CollectionFieldOps on Field<TEntity, List<TElement>>
FieldOps on Field<TEntity, TValue>
Extension methods for easier filter creation
FieldSortOps on Field<TEntity, TValue>
Extension methods for sorting on fields
FilterOps on Filter<TEntity>
NullableStringFieldOps on Field<TEntity, String?>
OptExtension on T
Extension to allow calling opt() on any value
StringFieldOps on Field<TEntity, String>
ZorphyQueryIterableExt on Iterable<T>
Extension methods for in-memory querying of iterables

Constants

alwaysThrows → const Object
Annotation marking a function as always throwing.
awaitNotRequired → const Object
Annotation on asynchronous function whose Future can be ignored.
checked → const Object
Annotation that no longer has any effect.
doNotStore → const Object
Annotation on function or property whose value must not be stored.
doNotSubmit → const Object
Annotation marking declaration that should be removed before publishing.
experimental → const Object
Annotation marking declaration as experimental and subject to change.
factory → const Object
Annotation on a function that creates new objects.
immutable → const Immutable
Annotation on an immutable class.
internal → const Object
Annotation on declaration that should not be used outside of its package.
isTest → const Object
Annotation on a test framework function that introduces a single test.
isTestGroup → const Object
Annotation on a test framework function that introduces a group of tests.
literal → const Object
Annotation on constructor that must be invoked with const if possible.
mustBeConst → const Object
Annotation on a parameter whose arguments must be constants.
mustBeOverridden → const Object
Annotation on instance members that must be overridden by subclasses.
mustCallSuper → const Object
Annotation on instance member that overriding members must call.
nonVirtual → const Object
Annotation on instance member that must not be overridden.
optionalTypeArgs → const Object
Annotation on type arguments that can safely be omitted.
protected → const Object
Annotation on instance member that should only be used by subclasses.
redeclare → const Object
Annotation on extension type members which redeclare superinterface members.
reopen → const Object
Annotation on declaration with less access restrictions than superinterface.
required → const Required
Annotation on named parameter that should always have an argument supplied.
sealed → const Object
Annotation on class that must not be subclassed outside of its package.
useResult → const UseResult
Annotation on function or property whose value must not be ignored.
virtual → const Object
Annotation which no longer has any effect.
visibleForOverriding → const Object
Annotation on declaration that should not be used outside of its package.
visibleForTesting → const Object
Annotation on a public declaration that should only be used in tests.
zorphy → const Zorphy
normal class; prepend class with a single dollar & make abstract
zorphy2 → const Zorphy2
Deprecated alias of zorphy.
ZValueObject → const Zorphy
Annotation alias for a value object: @ZValueObject expands to @Zorphy(kind: ZorphyKind.valueObject).

Functions

$checkedConvert<T>(Map map, String key, T castFunc(dynamic), {Object? readValue(Map, String)?}) → T
Helper function used in generated code when JsonSerializableGenerator.checked is true.
$checkedCreate<T>(String className, Map map, T constructor(S <S>(String, S (Object?), {Object? readValue(Map, String)?})), {Map<String, String> fieldKeyMap = const {}}) → T
Helper function used in generated code when JsonSerializableGenerator.checked is true.
$checkedNew<T>(String className, Map map, T constructor(), {Map<String, String>? fieldKeyMap}) → T
Helper function used in generated code when JsonSerializableGenerator.checked is true.
$checkKeys(Map map, {List<String>? allowedKeys, List<String>? requiredKeys, List<String>? disallowNullValues}) → void
Helper function used in generated fromJson code when JsonSerializable.disallowUnrecognizedKeys is true for an annotated type or JsonKey.required is true for any annotated fields.
$enumDecode<K extends Enum, V>(Map<K, V> enumValues, Object? source, {K? unknownValue}) → K
Returns the key associated with value source from enumValues, if one exists.
$enumDecodeNullable<K extends Enum, V>(Map<K, V> enumValues, Object? source, {Enum? unknownValue}) → K?
Returns the key associated with value source from enumValues, if one exists.
getFromJsonToGenericFn(Map<List<String>, dynamic Function(Map<String, dynamic>)> fns, Map<String, dynamic> json, List<String> genericType) → dynamic
Resolves the matching fromJson function for the provided generic type ids.
getGenericToJsonFn(Map<Type, Object? Function(Never)> fns, Type type) → Object? Function(Never)
Resolves a generic toJson function for the provided type.
hashObjects(Iterable objects) → int
Generates a hash code for multiple objects.

Exceptions / Errors

BadKeyException
A base class for exceptions thrown when decoding JSON.
CheckedFromJsonException
Exception thrown if there is a runtime exception in fromJson code generated when JsonSerializableGenerator.checked is true
DisallowedNullValueException
Exception thrown if there are keys with disallowed null values in a JSON map that was provided during deserialization.
MissingRequiredKeysException
Exception thrown if there are missing required keys in a JSON map that was provided during deserialization.
UnrecognizedKeysException
Exception thrown if there are unrecognized keys in a JSON map that was provided during deserialization.