MixinDeclaration constructor

const MixinDeclaration()

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

This interface combines both SourceDeclaration and TypeDeclaration, allowing it to be used both as a type descriptor and a declaration node.

Implementation

const MixinDeclaration();