ExtensionDeclaration class abstract
Represents a Dart extension
declaration at runtime.
Provides access to the type being extended and the members defined in the extension (methods, getters, setters, etc.).
Example
extension MyStringExtension on String {
String reversed() => split('').reversed.join();
}
final extension = reflector.reflectExtension('MyStringExtension');
print(extension.getExtendedType().getName()); // String
for (final member in extension.getMembers()) {
print(member.getName()); // reversed
}
- Inheritance
-
- Object
- Declaration
- EntityDeclaration
- SourceDeclaration
- ExtensionDeclaration
Constructors
- ExtensionDeclaration()
-
Represents a Dart
extension
declaration at runtime.const
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
-
getAnnotations(
) → List< AnnotationDeclaration> -
Returns all annotations applied to this declaration.
inherited
-
getDartType(
) → DartType? -
The analyzer DartType of the entity for enhanced type operations.
inherited
-
getDebugIdentifier(
) → String -
The debug identifier for the entity.
inherited
-
getElement(
) → Element? -
The analyzer element associated with this declaration.
inherited
-
getExtendedType(
) → TypeDeclaration - Returns the TypeDeclaration that this extension is declared on.
-
getIsPublic(
) → bool -
Checks if this declaration is a public declaration.
inherited
-
getIsSynthetic(
) → bool -
Checks if a declaration is a synthetic declaration.
inherited
-
getMembers(
) → List< MemberDeclaration> - Returns the list of members (methods, fields, etc.) defined in this extension.
-
getName(
) → String -
Gets the name of the declared element.
inherited
-
getParentLibrary(
) → LibraryDeclaration -
Returns the LibraryDeclaration in which this declaration is defined.
inherited
-
getSourceLocation(
) → Uri? -
Returns the source code location (e.g., file path or URI) where this declaration is defined,
or
null
if not available in the current reflection context.inherited -
getType(
) → Type -
Gets the runtime type of the declared element.
inherited
-
hasAnalyzerSupport(
) → bool -
Returns true if this declaration has analyzer information available.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object> -
Returns a JSON representation of this entity.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited