# getMethod method

1. @override

Method getMethod([

1. String? methodName

])
override

Retrieves a top-level method by its name.

- If `methodName` is provided, it returns the matching method.
- If omitted or `null`, it may return a default method depending on the implementation.

### Example

    final mainMethod = resource.getMethod('main');
    print('Method: ${mainMethod.name}');

## Implementation

    @override
    Method getMethod([String? methodName]) {
      var declaration = _methodDeclarations.find((d) => d.getName() == methodName);
      if(declaration == null) {
        throw _throwIfNotFound(methodName);
      }

      return Method.declared(declaration, ProtectionDomain.system());
    }