Implements<T extends Object?> class
Marks a union type to implement the interface stringType or type T.
In the case below City
will implement AdministrativeArea<House>
.
@freezed
abstract class Example with _$Example {
const factory Example.person(String name, int age) = Person;
@Implements<AdministrativeArea<House>>()
const factory Example.city(String name, int population) = City;
}
If interface is generic the Implements.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 interface 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 interface defines a method or a getter, that you implement in the class, you need to use the Custom getters and methods instructions.
Constructors
- Implements()
-
Marks a union type to implement the interface T.
const
- Implements.fromString(String? stringType)
-
Marks a union type to implement the interface
stringType
. This constructor must be used when implementing 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