lazyPutAsync<S> method
Registers an asynchronous lazy builder in this scope.
The builder is executed only when the dependency is first requested via findAsync.
Parameters:
Implementation
Future<S> Function() lazyPutAsync<S>(
Future<S> Function() builder, {
String? tag,
bool permanent = false,
bool isFactory = false,
}) {
final key = _getKey<S>(tag);
if (!isFactory &&
_registry.containsKey(key) &&
_registry[key]!.isInstantiated) {
return () => findAsync<S>(tag: tag);
}
final info = LevitDependency<S>(
asyncBuilder: builder,
permanent: permanent || isFactory,
isLazy: true,
isFactory: isFactory,
);
_registerBinding(key, info, isFactory ? 'putFactoryAsync' : 'lazyPutAsync',
tag: tag);
return () => findAsync<S>(tag: tag);
}