fromPlexAsync<T> function

Future<T> fromPlexAsync<T>({
  1. String? tag,
})

Implementation

Future<T> fromPlexAsync<T>({String? tag}) async {
  var elements = _injectors.whereType<_PlexInjector<T>>().toList();
  if (tag != null) {
    elements = elements.where((element) => element.tag == tag).toList();
  } else {
    elements = elements.where((element) => element.tag == null).toList();
  }
  elements = elements.where((e) => e.isAsync).toList();
  if (elements.isEmpty) {
    throw Exception("No async dependency provided for $T. Use injectSingletonLazyAsync(...)");
  }
  final injector = elements.first;
  return injector.getValueAsync();
}