DependencyFactory<T extends DependencyContainer> class
abstract
An abstract class representing a factory responsible for creating instances of a specific type of DependencyContainer.
The DependencyFactory is designed to define a blueprint for creating dependency containers, which are typically used for managing application dependencies in a structured and reusable way.
Type Parameter:
T: A subtype of DependencyContainer, ensuring that only valid dependency containers are created by this factory.
Usage:
- Extend this class and implement the create method to define how to construct the specific dependency container.
Example:
class MyDependencyContainer extends DependencyContainer {
final String value;
MyDependencyContainer(this.value);
}
class MyDependencyFactory extends DependencyFactory<MyDependencyContainer> {
@override
Future<MyDependencyContainer> create() async {
return MyDependencyContainer('Initialized Dependency');
}
}
void main() async {
final factory = MyDependencyFactory();
final container = await factory.create();
print(container.value); // Outputs: Initialized Dependency
}
Constructors
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
-
create(
) → FutureOr< T> - Asynchronously creates an instance of the dependency container.
-
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