Parameter class abstract interface

Provides reflective access to method/constructor parameter metadata.

This interface enables inspection of:

  • Parameter types and positions
  • Optional/required status
  • Named vs positional parameters
  • Default values
  • Annotations

{@template parameter_interface_features}

Key Features

  • Type-safe parameter type access
  • Default value inspection
  • Parameter kind detection (named/positional)
  • Signature generation
  • Annotation support

Implementation Notes

Concrete implementations typically wrap platform-specific reflection objects while providing this uniform interface.

Example Usage

// Get parameter metadata
final params = method.getParameters();
final firstParam = params[0];

// Inspect parameter properties
print('Name: ${firstParam.getName()}');
print('Type: ${firstParam.getType<dynamic>().getName()}');
print('Optional: ${firstParam.isOptional()}');

// Check for default value
if (firstParam.hasDefaultValue()) {
  print('Default: ${firstParam.getDefaultValue()}');
}

{@endtemplate}

Inheritance

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
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
getClass() Class<Object>
Gets the type of the parameter with proper generics.
getDeclaration() Declaration
Gets the type declaration metadata for this class.
inherited
getDefaultValue() → dynamic
Gets the default value of the parameter.
getDirectAnnotation<A>() → A?
Gets a single annotation by type, if present.
inherited
getDirectAnnotations<A>() List<A>
Gets all annotations of a specific type.
inherited
getIndex() int
Gets the parameter's position in the parameter list.
getMember() Member
Gets the member that this parameter belongs to.
getName() String
Gets the declared name of the source.
inherited
getProtectionDomain() ProtectionDomain
Gets the protection domain governing access to this element.
inherited
getSignature() String
Gets the executable signature as a string.
inherited
getType() Type
Gets the type of the parameter.
hasDefaultValue() bool
Checks if this parameter has a default value.
hasDirectAnnotation<A>() bool
Checks if this element has a specific annotation.
inherited
isNamed() bool
Checks if this is a named parameter.
isOptional() bool
Checks if this parameter is optional.
isPositional() bool
Checks if this is a positional parameter.
isPublic() bool
Checks if this element is public.
inherited
isRequired() bool
Checks if this parameter is required.
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

Static Methods

declared(ParameterDeclaration declaration, ProtectionDomain domain) Parameter
Creates a Parameter instance from reflection metadata.