put<S> method

S put<S>(
  1. S dependency, {
  2. String? tag,
  3. bool permanent = false,
})

Injects an instance <S> in memory to be globally accessible.

No need to define the generic type <S> as it's inferred from the dependency

  • dependency The Instance to be injected.
  • tag optionally, use a tag as an "id" to create multiple records of the same Type<S>
  • permanent keeps the Instance in memory, not following Get.smartManagement rules.

Implementation

S put<S>(
  S dependency, {
  String? tag,
  bool permanent = false,
}) {
  _insert(
    isSingleton: true,
    name: tag,
    permanent: permanent,
    builder: () => dependency,
  );
  return find<S>(tag: tag);
}