registerLazySingleton<T> method
Shorthand for registering a factory that injects a singleton when it runs.
In many cases, you might prefer this to registerFactory.
Returns f
.
Implementation
T Function(Container) registerLazySingleton<T>(T Function(Container) f, {Type? as}) {
return registerFactory<T>(
(container) {
var r = f(container);
container.registerSingleton<T>(r, as: as);
return r;
},
as: as,
);
}