BeanDefinition class

Represents a bean definition in the DI container

Contains all metadata about a bean including its type, scope, qualifiers, and creation instructions.

Constructors

BeanDefinition({required Type type, required String name, required Function factory, ScopeType scope = ScopeType.singleton, String? qualifier, List<String> profiles = const [], bool isPrimary = false, bool isLazy = false, List<Type> dependencies = const [], List<ParameterDefinition> constructorParameters = const [], List<FieldDefinition> injectableFields = const [], List<Conditional> conditions = const [], String? initMethod, String? destroyMethod})

Properties

conditions List<Conditional>
Conditional annotations that must be satisfied
final
constructorParameters List<ParameterDefinition>
Constructor parameters metadata
final
dependencies List<Type>
Dependencies required for this bean
final
destroyMethod String?
Destroy method name (if any)
final
factory Function
Factory function to create the bean instance
final
hashCode int
The hash code for this object.
no setteroverride
initMethod String?
Initialization method name (if any)
final
injectableFields List<FieldDefinition>
Fields that need injection
final
isLazy bool
Whether this bean is lazy-initialized
final
isPrimary bool
Whether this bean is primary (preferred when multiple candidates exist)
final
name String
The name/identifier of the bean
final
profiles List<String>
Profiles under which this bean is active
final
qualifier String?
Optional qualifier for disambiguation
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope ScopeType
The scope of the bean (singleton, prototype, etc.)
final
type Type
The runtime type of the bean
final

Methods

clearSingletonInstance() → void
Clears the singleton instance (useful for testing)
getInstance() Object
Gets or creates the bean instance based on scope
isActiveForProfiles(List<String> activeProfiles) bool
Checks if this bean is active for the given profiles
matchesQualifier(String? requestedQualifier) bool
Checks if this bean matches the given qualifier
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override