ZorphyNamedConstructor class
Annotation to declare a named constructor with a custom body on the generated concrete class.
Place one or more @ZorphyNamedConstructor annotations on the
abstract class. The generated concrete class will have additional
named constructors with the same parameters as the default
constructor, plus the custom body code.
Example:
@ZValueObject
@ZorphyNamedConstructor(name: 'world', body: r'assert(!name.startsWith("WINDOW-ID-"));')
abstract class $ContentWorld {
String get name;
}
This generates:
class ContentWorld {
final String name;
ContentWorld({required this.name});
ContentWorld.world({required this.name}) {
assert(!name.startsWith("WINDOW-ID-"));
}
}
Constructors
- ZorphyNamedConstructor({required String name, required String body, bool factory = false})
-
Creates a named constructor descriptor.
const
Properties
- body → String
-
Dart statements executed in the constructor body.
final
- factory → bool
-
When
true, emit afactoryconstructor (see body for the contract).final - hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The constructor name (e.g.
worldproducesContentWorld.world(...)).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited