A handle that looks up a bean of T each time get is called: the
JSR-330 form of a lazy dependency (jakarta.inject.Provider).
An injection point of this type gets the same provider as an
ObjectProvider<T> (which implements it): each get resolves the bean
as if it were injected into the bean that holds the provider. Use it
for a bean needed fresh on every use, or to break a cycle;
ObjectProvider<T> offers more methods.
// The clock is looked up on every call.
import 'package:spring_core_dart/jakarta.dart' as jakarta;
@Named()
class Checkout {
Checkout(this.clock);
final jakarta.Provider<Clock> clock;
DateTime now() => clock.get().now();
}
Spring (Java):
@Named
class Checkout {
@Inject Provider<Clock> clock;
Instant now() { return clock.get().instant(); }
}
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
) → T -
The bean, looked up now. Throws
NoSuchBeanDefinitionExceptionwhen none matches andNoUniqueBeanDefinitionExceptionwhen several match and none wins. -
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