morphy top-level constant
Morphy
const morphy
normal class; prepend class with a single dollar & make abstract
abstract class $MyClass { ...
define non final get properties only (no constructor)
String get aValue;
int? get nullableValue;
to instantiate or use the class omit the dollar
MyClass(aValue: "x");
to implement an interface use implements
@morphy
abstract class $B implements $$A<int, String> {
String get z;
ensure the generic names are the same between inherited classes
class $A<T1> { ...
class $B<T1> extends $A<T1> { ...
abstract classes; prepend class with two dollars
class $$myAbstractClass { ...
private constructor for custom constructors; postpend with underscore
abstract class $A_ {
this then allows default values by defining custom functions in the same file
A_ AFactory() {
return A_._(a: "my default value");
}
it makes it explict that the default constructor cannot be used
constant constructors
abstract class $A {
int get a;
const $A();
}
must add a const $A() constructor to abstract class
Implementation
const morphy = Morphy(
generateJson: false,
explicitSubTypes: null,
explicitToJson: true,
generateCompareTo: true,
generateCopyWithFn: false,
);