ClassPathResource class abstract

Provides access to resources, classes, methods, and fields located in a package's classpath.

A ClassPathResource abstracts the ability to query package-level declarations such as classes, methods, and fields. This provides a better api for developers who wants to explore the classpath of a package.

Example

void main() {
  final resource = MyClassPathResource('package:my_app/src/models/user.dart');

  // Get package metadata
  final pkg = resource.getPackage();
  print('Package: ${pkg.name}');

  // Lookup a specific class
  final userClass = resource.getClass(User);

  // List all classes in the package
  final classes = resource.getClasses();
  print('Classes: ${classes.map((c) => c.name).toList()}');

  // Retrieve top-level methods
  final methods = resource.getMethods();
  print('Methods: ${methods.map((m) => m.name).toList()}');
}

This class is abstract and must be implemented by subclasses that define how to load and resolve package resources.

Implemented types
Implementers

Constructors

ClassPathResource(String packageUri)
Provides access to resources, classes, methods, and fields located in a package's classpath.

Properties

hashCode int
The hash code for this object.
no setterinherited
packageUri String
The package URI associated with this resource.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getClass([Type? type]) Class
Retrieves a class by its name from the package.
getClasses() List<Class>
Returns all classes defined in the package.
getInputStream() InputStream
Returns a new InputStream to read the underlying content.
inherited
getMethod([String? methodName]) Method
Retrieves a top-level method by its name.
getMethods() List<Method>
Returns all top-level methods defined in the package.
getPackage() Package
Retrieves metadata about the package.
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