ClassType<T> class
The ClassType class in Jetleaf represents a reference to a Dart
class, optionally including metadata such as package, protection domain,
or type declaration.
It provides a convenient way to convert a class reference into a Class instance used by the Jetleaf framework for reflection, conditional processing, or pod registration. ClassType serves as a bridge between compile-time type information and runtime class metadata in JetLeaf's type system infrastructure.
Key Features:
- Supports optional class name, package, ProtectionDomain, and ClassDeclaration.
- Can convert itself into a Class instance using toClass.
- Integrates with Jetleaf's type system for dynamic class handling.
- Provides multiple factory constructors for flexible class reference creation.
- Supports equality and hash code operations for use in collections.
Usage Example:
import 'package:jetleaf/jetleaf.dart';
// Create a ClassType by name
final simpleClass = ClassType(name: 'UserService');
// Convert to a Jetleaf Class instance
final userClass = simpleClass.toClass();
// Create a ClassType with a ClassDeclaration
final declaredClass = ClassType(declaration: someTypeDeclaration);
final declaredClassInstance = declaredClass.toClass();
// Use in pod registration
@Pod
class ServiceConfiguration {
@Provide
UserService userService() => UserService();
@Provide
ClassType<UserService> userServiceType() => ClassType<UserService>();
}
- Implemented types
- Mixed-in types
- Annotations
-
- @Generic(ClassType)
Constructors
- ClassType([String? package, String? name, ProtectionDomain? pd, ClassDeclaration? declaration, String? qualifiedName])
-
The
ClassTypeclass in Jetleaf represents a reference to a Dart class, optionally including metadata such as package, protection domain, or type declaration.const - ClassType.declared(ClassDeclaration? declaration, [String? qualifiedName, String? name, ProtectionDomain? pd, String? package])
-
Creates a ClassType from a ClassDeclaration.
const
- ClassType.named(String? name, String? package, [String? qualifiedName, ProtectionDomain? pd, ClassDeclaration? declaration])
-
Creates a ClassType from a class name and package.
const
- ClassType.qualified(String? qualifiedName, [String? name, ProtectionDomain? pd, ClassDeclaration? declaration, String? package])
-
Creates a ClassType from a fully qualified class name.
const
Properties
- declaration → ClassDeclaration?
-
Optional ClassDeclaration that represents the class declaration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String?
-
The simple name of the class.
final
- package → String?
-
The package the class belongs to, if any.
final
- pd → ProtectionDomain?
-
The ProtectionDomain associated with this class reference.
final
- qualifiedName → String?
-
Contains the full URI of the class with the class name.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
equalizedProperties(
) → List< Object?> -
Provides the properties used for equality comparison and hash code generation.
override
-
getType(
) → Type -
Returns the compile-time generic type parameter
Tof this ClassType. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toClass(
) → Class< T> -
Converts this ClassType into a Class instance for use by Jetleaf.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited