putAsync<S> method
Future<S>
putAsync<S>(
- AsyncInstanceBuilderCallback<
S> builder, { - String? tag,
- bool permanent = false,
Injects an instance of S built asynchronously by builder into the
dependency manager.
Awaits builder and then registers the resulting instance exactly like
put, so the regular lifecycle (onInit/onReady) runs on the ready
instance. Perform any asynchronous setup inside builder before
returning the instance; lifecycle callbacks such as onInit are
synchronous and are not awaited.
await Get.putAsync<StorageService>(() async {
final service = StorageService();
await service.init();
return service;
});
tagOptional tag to identify this specific instance.permanentIf true, prevents the instance from being deleted by SmartManagement.
Implementation
Future<S> putAsync<S>(
AsyncInstanceBuilderCallback<S> builder, {
String? tag,
bool permanent = false,
}) async {
return put<S>(await builder(), tag: tag, permanent: permanent);
}