registerFactory<T> method
Registers a factory. Any attempt to resolve the
type within this container will return the result of f
.
Returns f
.
Implementation
T Function(Container) registerFactory<T>(T Function(Container) f, {Type? as}) {
as ??= T;
if (_factories.containsKey(as)) {
throw StateError('This container already has a factory for $as.');
}
_factories[as] = f;
return f;
}