getMethod abstract method

MethodDeclaration? getMethod(
  1. String methodName
)

Returns a method by its methodName, or null if no method with that name exists.

Useful for dynamic invocation or analyzing a specific method’s parameters, return type, and metadata.

Example

final addMethod = clazz.getMethod('add');
if (addMethod != null) {
  print(addMethod.getReturnType().getName()); // int
}

Implementation

MethodDeclaration? getMethod(String methodName);