put<T> static method

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

Registers (or reuses) an instance.

If already registered, returns the existing one (does not claim ownership). Otherwise calls Get.put<T> and marks this scope as the owner.

Implementation

static T put<T>(
  T dependency, {
  String? tag,
  bool permanent = false,
  bool? overrideSmartManagement, // kept for signature parity; unused
}) {
  if (Get.isRegistered<T>(tag: tag)) {
    return Get.find<T>(tag: tag);
  }
  final res = Get.put<T>(dependency, tag: tag, permanent: permanent);
  _active?.ownInstance<T>(tag: tag);
  return res;
}