Represents a reflected Dart mixin declaration, providing access to its
members, type constraints, and metadata.
Mixins in Dart allow code reuse across multiple class hierarchies. This interface provides runtime introspection of mixin declarations, including their fields, methods, type constraints, and annotations.
Example
mixin TimestampMixin on BaseModel {
DateTime? createdAt;
DateTime? updatedAt;
void updateTimestamp() {
updatedAt = DateTime.now();
}
}
final mixinType = reflector.reflectType(TimestampMixin).asMixinType();
print(mixinType?.getName()); // TimestampMixin
print(mixinType?.getFields().length); // 2
print(mixinType?.getMethods().length); // 1
- Inheritance
-
- Object
- BaseDeclaration
- Declaration
- EntityDeclaration
- SourceDeclaration
- ClassDeclaration
- MixinDeclaration
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString.inherited -
getAnnotations(
) → List< AnnotationDeclaration> -
Returns all annotations applied to this declaration in source code.
inherited
-
getConstraints(
) → List< LinkDeclaration> -
Returns the
onconstraint types for this mixin. -
getConstructors(
) → List< ConstructorDeclaration> -
Returns all constructors declared in this class.
inherited
-
getDebugIdentifier(
) → String -
Returns the stable debug identifier for this entity.
inherited
-
getField(
String fieldName) → FieldDeclaration? -
Returns a field by its
fieldName, ornullif no field with that name exists.inherited -
getFields(
) → List< FieldDeclaration> -
Returns all fields declared in this class, excluding inherited fields.
inherited
-
getHasConstraints(
) → bool -
Returns
trueif this mixin declaresontype constraints. -
getHasInterfaces(
) → bool -
Returns
trueif this class implements one or more interfaces.inherited -
getInstanceFields(
) → List< FieldDeclaration> -
Returns all instance fields declared in this class or mixin.
inherited
-
getInstanceMethods(
) → List< MethodDeclaration> -
Returns all instance methods declared in this class or mixin.
inherited
-
getInterfaces(
) → List< LinkDeclaration> -
Returns the list of interfaces this type implements.
inherited
-
getIsAbstract(
) → bool -
Returns
trueif this class is markedabstract.inherited -
getIsBase(
) → bool -
Returns
trueif this class is declared as base.inherited -
getIsFinal(
) → bool -
Returns
trueif this class is declared as final.inherited -
getIsInterface(
) → bool -
Returns
trueif this class is declared as an interface.inherited -
getIsMixin(
) → bool -
Returns
trueif this declaration is amixinor a mixin application.inherited -
getIsPublic(
) → bool -
Indicates whether this declaration is publicly visible.
inherited
-
getIsRecord(
) → bool -
Returns
trueif this class represents a record class.inherited -
getIsSealed(
) → bool -
Returns
trueif this class is declared as sealed.inherited -
getIsSynthetic(
) → bool -
Indicates whether this declaration is synthetic.
inherited
-
getKind(
) → TypeKind -
Returns the TypeKind describing what kind of type this declaration represents.
inherited
-
getLibrary(
) → LibraryDeclaration -
Returns the LibraryDeclaration in which this class is declared.
inherited
-
getMembers(
) → List< MemberDeclaration> -
Returns all members declared in this class, including fields, methods, and constructors.
inherited
-
getMethod(
String methodName) → MethodDeclaration? -
Returns a method by its
methodName, ornullif no method with that name exists.inherited -
getMethods(
) → List< MethodDeclaration> -
Returns all methods declared in this class, excluding inherited methods.
inherited
-
getMixins(
) → List< LinkDeclaration> -
Returns the list of mixin identities that are applied to this type.
inherited
-
getName(
) → String -
Returns the simple (unqualified) name of this declaration.
inherited
-
getPackageUri(
) → String -
Returns the package URI in which this class is declared.
inherited
-
getQualifiedName(
) → String -
Returns the fully-qualified identifier for this object.
inherited
-
getSimpleName(
) → String -
Returns the simple (unqualified) name of this class.
inherited
-
getSourceLocation(
) → Uri? -
Returns the URI pointing to the source location where this declaration
is defined.
inherited
-
getStaticFields(
) → List< FieldDeclaration> -
Returns all static fields declared in this class or mixin.
inherited
-
getStaticMethods(
) → List< MethodDeclaration> -
Returns all static methods declared in this class or mixin.
inherited
-
getSuperClass(
) → LinkDeclaration? -
Returns the direct superclass of this type.
inherited
-
getType(
) → Type -
Returns the Dart Type represented by this declaration.
inherited
-
getTypeArguments(
) → List< LinkDeclaration> -
Returns the list of type arguments for generic types.
inherited
-
hasField(
String fieldName) → bool -
Checks if this class or mixin declares a field with the given
fieldName.inherited -
hasMethod(
String methodName) → bool -
Checks if this class or mixin declares a method with the given
methodName.inherited -
isGeneric(
) → bool -
Returns
trueif this class declares generic type parameters.inherited -
newInstance(
Map< String, dynamic> arguments) → dynamic -
Instantiates this class using the default (unnamed) constructor.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
BinaryBuilder builder) → void -
Serializes this declaration to binary format.
inherited
-
toJson(
) → Map< String, Object> -
Serializes this declaration into a JSON-compatible map.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited