find<S> method

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

Finds the registered type <S> (or tag) In case of using Sint.create to register a type <S> or tag, it will create an instance each time you call find. If the registered type <S> (or tag) is a Controller, it will initialize it's lifecycle.

Implementation

S find<S>({String? tag}) {
  final key = _getKey(S, tag);
  final dep = _singl[key];
  if (dep == null) {
    // ignore: lines_longer_than_80_chars
    throw '"$S" not found. You need to call "Sint.put($S())" or "Sint.lazyPut(()=>$S())"';
  }

  /// although dirty solution, the lifecycle starts inside
  /// `initDependencies`, so we have to return the instance from there
  /// to make it compatible with `Sint.create()`.
  final i = _initDependencies<S>(name: tag);
  return i ?? dep.getDependency() as S;
}