With<T extends Object?> class

Marks a union type to mixin the interface stringType or type T. In the case below City will mixin with AdministrativeArea<House>.

@freezed
abstract class Example with _$Example {
  const factory Example.person(String name, int age) = Person;

  @With<AdministrativeArea<House>>()
  const factory Example.city(String name, int population) = City;
}

If interface is generic the With.fromString constructor must be used otherwise freezed will generate correct code but dart will throw a load error on the annotation declaration.

Note: You need to make sure that you comply with the interface requirements by implementing all the abstract members. If the mixin has no members or just fields, you can fulfil the interface contract by adding them in the constructor of the union type. Keep in mind that if the mixin defines a method or a getter, that you implement in the class, you need to use the Custom getters and methods instructions.

Constructors

With()
Marks a union type to mixin the interface T.
const
With.fromString(String? stringType)
Marks a union type to mixin the interface stringType. This constructor must be used when mixing in a generic class with a generic type parameter e.g. AdministrativeArea<T> otherwise dart will throw a load error when compiling the annotation.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringType String?
final

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