A lightweight class reference containing minimal structural information about a Dart class.
ClassReference exists to provide just enough metadata to:
- Identify a class uniquely via its qualified name
- Describe its raw Dart Type
- Establish superclass and interface relationships
This minimal representation is intentionally designed for fast graph traversal, particularly when resolving subclass and interface relationships without materializing full ClassDeclaration objects.
Purpose
ClassReference is primarily used during:
- Subclass discovery
- Type hierarchy traversal
- Dependency and inheritance graph analysis
By avoiding full declaration loading, it enables O(1) lookups and minimizes memory overhead in large reflection graphs.
Design Notes
- Implements QualifiedName to guarantee a stable, unique identifier
- Exposes the raw Dart Type for fast runtime comparisons
- Stores only structural relationships (superclass and interfaces)
- Intentionally omits members, annotations, generics, and metadata
This makes ClassReference ideal for internal indexing, caching, and
hierarchy resolution, rather than full introspection.
Example
final ref = runtime.getClassReference(MyService);
print(ref.getQualifiedName()); // dart:core.MyService
print(ref.getType() == MyService); // true
final superClass = ref.getSuperClass();
final interfaces = ref.getInterfaces();
See Also
- ClassDeclaration for full structural metadata
- Class for runtime reflection and instantiation
- LinkDeclaration for build-time type references
- Implemented types
- Mixed-in 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 -
getInterfaces(
) → List< ClassReference> - Returns the list of interfaces implemented by this class.
-
getQualifiedName(
) → String -
Returns the fully-qualified identifier for this object.
inherited
-
getSuperClass(
) → ClassReference? - Returns the direct superclass of this class, if any.
-
getType(
) → Type - Returns the raw Dart Type represented by this class reference.
-
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