find<S> method

S find<S>({
  1. String? tag,
})

Retrieves an instance of type S.

Implementation

S find<S>({String? tag}) {
  final key = _getKey(S, tag);
  if (_factories.containsKey(key)) {
    final dep = _factories[key]!;
    final instance = dep.getDependency() as S;
    if (!dep.isInit) {
      dep.isInit = true;
      if (instance is GetLifeCycleMixin) {
        instance.onStart();
      }
    }
    return instance;
  }
  throw InstanceNotFoundException(
    'Instance "$S" with tag "$tag" not found in GetContainer.',
  );
}