registerLazySingletonAsync<T extends Object> abstract method

void registerLazySingletonAsync<T extends Object>(
  1. FactoryFuncAsync<T> factoryFunc,
  2. {String? instanceName,
  3. DisposingFunc<T>? dispose}
)

registers a type as Singleton by passing an async factory function that will be called on the first call of getAsync on that type This is a rather esoteric requirement so you should seldom have the need to use it. This factory function factoryFunc isn't called immediately but wait till the first call by getAsync() or isReady() is made To control if an async Singleton has completed its factoryFunc gets a Completer passed as parameter that has to be completed to signal that this instance is ready. Therefore you have to ensure that the instance is ready before you use get on it or use getAsync() to wait for the completion. You can wait/check if the instance is ready by using isReady() and isReadySync(). instanceName if you provide a value here your instance gets registered with that name instead of a type. This should only be necessary if you need to register more than one instance of one type. registerLazySingletonAsync does not influence allReady however you can wait for and be dependent on a LazySingleton.

Implementation

void registerLazySingletonAsync<T extends Object>(
  FactoryFuncAsync<T> factoryFunc, {
  String? instanceName,
  DisposingFunc<T>? dispose,
});