SourceDeclaration class abstract final

A declaration that originates directly from source-level Dart code.

SourceDeclaration represents declarations that can be traced back to a concrete location in source code, such as:

  • Classes
  • Members (methods, fields, constructors)
  • Top-level declarations

Unlike purely synthetic or runtime-only declarations, source declarations may expose:

  • Annotations applied in code
  • A source URI pointing to their definition

Identity

The debug identity for a SourceDeclaration is derived from:

  • The declaration’s runtime type
  • Its simple name

This ensures stability across reflection and generation phases while remaining human-readable.


Serialization

SourceDeclaration provides a standardized toJson implementation containing:

  • Declaration kind
  • Name
  • Annotations (if any)
  • Source location (if available)
  • Runtime type information

This structure is used extensively by:

  • Diagnostic tooling
  • Debug output
  • Metadata inspection
Inheritance
Implementers

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, and toString.
inherited
getAnnotations() → List<AnnotationDeclaration>
Returns all annotations applied to this declaration in source code.
getDebugIdentifier() → String
Returns the stable debug identifier for this entity.
override
getIsPublic() → bool
Indicates whether this declaration is publicly visible.
inherited
getIsSynthetic() → bool
Indicates whether this declaration is synthetic.
inherited
getName() → String
Returns the simple (unqualified) name of this declaration.
inherited
getSourceLocation() → Uri?
Returns the URI pointing to the source location where this declaration is defined.
getType() → Type
Returns the Dart Type represented by this declaration.
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.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited