Executable class abstract

Abstract base class for executable elements (methods, constructors, functions).

Provides common functionality for inspecting and working with callable elements including parameters, invocation validation, and signature generation.

{@template executable_element_features}

Key Features

  • Parameter inspection and validation
  • Signature generation
  • Invocation argument checking
  • Const/var/final determination

Implementations

Typically implemented by:

  • MethodElement for class methods
  • ConstructorElement for constructors
  • FunctionElement for standalone functions

Example Usage

// Get executable element from reflection
final methodElement = classElement.getMethod('calculate');

// Check parameters
if (methodElement.getParameterCount() > 0) {
  final firstParam = methodElement.getParameterAt(0);
  print('First parameter: ${firstParam.getName()}');
}

// Validate arguments
if (methodElement.canAcceptArguments({'x': 1, 'y': 2})) {
  print('Method can accept these named arguments');
}

{@endtemplate}

Inheritance
Implementers

Constructors

Executable()

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

annotationMatches<A>(Annotation annotation) bool
inherited
canAcceptArguments(Map<String, dynamic> arguments) bool
Checks if named arguments can be accepted.
canAcceptNamedArguments(Map<String, dynamic> arguments) bool
Checks if named arguments can be accepted.
canAcceptPositionalArguments(List args) bool
Checks if positional arguments can be accepted.
checkAccess(String operation, DomainPermission permission) → void
Verifies access permissions before performing sensitive operations.
inherited
getAllDirectAnnotations() List<Annotation>
Gets all annotations applied to this element.
inherited
getDeclaration() Declaration
Gets the type declaration metadata for this class.
inherited
getDirectAnnotation<A>() → A?
Gets a single annotation by type, if present.
inherited
getDirectAnnotations<A>() List<A>
Gets all annotations of a specific type.
inherited
getName() String
Gets the declared name of the source.
inherited
getParameter(String name) Parameter?
Gets a parameter by name.
getParameterAt(int index) Parameter?
Gets a parameter by index.
getParameterCount() int
Gets the total number of parameters.
getParameters() List<Parameter>
Gets all parameters of this executable element.
getParameterTypes() List<Class>
Gets the types of all parameters.
getProtectionDomain() ProtectionDomain
Gets the protection domain governing access to this element.
inherited
getSignature() String
Gets the executable signature as a string.
inherited
hasDirectAnnotation<A>() bool
Checks if this element has a specific annotation.
inherited
isConst() bool
Checks if this executable is declared as const.
isPublic() bool
Checks if this element is public.
inherited
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