StandardMixinDeclaration class final
A standard implementation of MixinDeclaration that provides reflection metadata about a Dart mixin declaration.
This class exposes the mixin's name, runtime type, type parameters, constraints, fields, methods, and other metadata necessary for runtime introspection of mixin declarations.
Example
mixin TimestampMixin on BaseModel {
DateTime? createdAt;
DateTime? updatedAt;
void updateTimestamp() {
updatedAt = DateTime.now();
}
}
final mixinReflection = StandardReflectedMixin(
name: 'TimestampMixin',
type: TimestampMixin,
parentLibrary: myLibrary,
constraints: [baseModelType],
fields: [createdAtField, updatedAtField],
methods: [updateTimestampMethod],
);
print(mixinReflection.getName()); // TimestampMixin
print(mixinReflection.getOnConstraints().length); // 1
This implementation supports all the standard reflection operations including type checking, member access, constraint inspection, and annotation access.
- Inheritance
- Implemented types
Constructors
-
StandardMixinDeclaration({List<
LinkDeclaration> constraints = const [], required String name, required Type type, required bool isPublic, required bool isSynthetic, String? qualifiedName, required LibraryDeclaration library, List<LinkDeclaration> typeArguments = const [], List<AnnotationDeclaration> annotations = const [], List<ConstructorDeclaration> constructors = const [], List<FieldDeclaration> fields = const [], List<LinkDeclaration> interfaces = const [], bool isAbstract = false, bool isBase = false, bool isFinal = false, bool isInterface = false, bool isMixin = true, bool isRecord = false, bool isSealed = false, List<MethodDeclaration> methods = const [], List<LinkDeclaration> mixins = const [], Uri? sourceLocation, LinkDeclaration? superClass, String? packageUri, String? simpleName}) - A standard implementation of MixinDeclaration that provides reflection metadata about a Dart mixin declaration.
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
-
copyWith(
{String? name, Type? type, LibraryDeclaration? library, List< LinkDeclaration> ? typeArguments, List<ConstructorDeclaration> ? constructors, List<FieldDeclaration> ? fields, List<MethodDeclaration> ? methods, LinkDeclaration? superClass, List<LinkDeclaration> ? interfaces, List<LinkDeclaration> ? mixins, List<AnnotationDeclaration> ? annotations, Uri? sourceLocation, bool? isAbstract, bool? isMixin, bool? isSealed, bool? isBase, bool? isInterface, bool? isFinal, bool? isRecord, String? qualifiedName, bool? isPublic, bool? isSynthetic}) → StandardClassDeclaration -
Creates a copy of this class with the specified properties changed.
inherited
-
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString.override -
getAnnotatedMethods(
) → List< String> -
Returns the method names on this class that have annotations.
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.override -
getConstructors(
) → List< ConstructorDeclaration> -
Returns all constructors declared in this class.
inherited
-
getDebugIdentifier(
) → String -
Returns the stable debug identifier for this entity.
override
-
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.override -
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
-
getSubClasses(
) → List< String> -
Returns the direct subclass names for this class.
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.
override
-
setAnnotatedMethods(
List< String> methodNames) → void -
Sets the annotated method names for this class.
inherited
-
setSubClasses(
List< String> subClassNames) → void -
Sets the direct subclass names for this class.
inherited
-
toJson(
) → Map< String, Object> -
Serializes this declaration into a JSON-compatible map.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateWith(
{List< ConstructorDeclaration> ? constructors, List<FieldDeclaration> ? fields, List<MethodDeclaration> ? methods, List<LinkDeclaration> ? constraints}) → StandardMixinDeclaration - Creates a copy of this mixin with the specified properties changed.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
deserialize(
BinaryReader reader) → StandardMixinDeclaration -
Deserializes a StandardMixinDeclaration from binary format.
override