# getClass method

1. @override

Class getClass([

1. Type? type

])
override

Retrieves a class by its name from the package.

- If `type` is provided, it returns the matching class.
- If omitted or `null`, returns a default or primary class.

### Example

    final userClass = resource.getClass(User);
    print('Found class: ${userClass.name}');

## Implementation

    @override
    Class getClass([Type? type]) {
      final className = type?.toString();
      var declaration = _declarations.find((d) => d.getSimpleName() == className);
      declaration ??= _findFromLibrary(className);
      if(declaration == null) {
        throw _throwIfNotFound(className);
      }

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