ObjectFactory<T> class
abstract
A generic factory interface for producing instances of a given type T.
Used by Jetleaf and dependency injection containers to lazily create or retrieve instances of objects—especially in scenarios where you want to delay instantiation until explicitly requested.
Implementations may return new instances each time, or cache and return the same instance (singleton-style).
Example
class MyFactory implements ObjectFactory<Foo> {
@override
Foo get() => Foo();
}
final factory = MyFactory();
final foo = factory.get();
In more complex scenarios, the factory might retrieve from a container:
class PodFactoryObjectFactory implements ObjectFactory<MyService> {
final PodFactory factory;
PodFactoryObjectFactory(this.factory);
@override
MyService get() => factory.get<MyService>();
}
- Implementers
- Annotations
-
- @Generic(ObjectFactory)
Constructors
- ObjectFactory()
-
A generic factory interface for producing instances of a given type
T.const
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
-
chain<
R> (ObjectFactory< R> nextFactory(T)) → Future<ObjectFactory< R> > - Creates a new ObjectFactory that uses this factory's output as input to another factory.
-
copyWith(
{ObjectFactoryFunction< T> ? creator}) → ObjectFactory<T> - Creates a copy of this ObjectFactory with a new creator function.
-
createMultiple(
int count) → Future< List< T> > -
Creates multiple instances of type
Tin a single call. -
get(
[List< ArgumentValue> ? args]) → FutureOr<ObjectHolder< T> > - Returns an instance of the object managed by this factory.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation of this ObjectFactory.
override
-
withSideEffect(
void sideEffect(T)) → Future< ObjectFactory< T> > - Creates a new factory that performs a side effect after object creation.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited