ParameterDeclaration class abstract
Represents a parameter in a constructor or method, with metadata about its name, type, position (named or positional), and default value.
Example
final method = clazz.getMethods().first;
for (final param in method.getParameters()) {
print(param.getName()); // e.g., "value"
print(param.getTypeDeclaration().getName()); // e.g., "String"
}
- Inheritance
-
- Object
- Declaration
- EntityDeclaration
- SourceDeclaration
- ParameterDeclaration
Constructors
- ParameterDeclaration()
-
Represents a parameter in a constructor or method, with metadata about
its name, type, position (named or positional), and default value.
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
-
getDefaultValue(
) → dynamic -
Returns the default value of the parameter, or
null
if none. -
getElement(
) → Element? -
The analyzer element associated with this declaration.
inherited
-
getHasDefaultValue(
) → bool -
Returns
true
if the parameter has a default value. -
getIndex(
) → int - The index of the parameter
-
getIsNamed(
) → bool -
Returns
true
if the parameter is a named parameter. -
getIsOptional(
) → bool -
Returns
true
if the parameter is optional (either named or positional). -
getIsPublic(
) → bool -
Checks if this declaration is a public declaration.
inherited
-
getIsSynthetic(
) → bool -
Checks if a declaration is a synthetic declaration.
inherited
-
getLinkDeclaration(
) → LinkDeclaration - Returns the LinkDeclaration of the parameter.
-
getMemberDeclaration(
) → MemberDeclaration - Returns the MemberDeclaration that this parameter belongs to.
-
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