put<S> static method

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

Register a dependency

Implementation

static S put<S>(S dependency, {String? tag, bool permanent = false}) {
  final type = S;
  if (!_dependencies.containsKey(type)) {
    _dependencies[type] = {};
  }
  _dependencies[type]![tag] = _InstanceBuilder(
    instance: dependency,
    permanent: permanent,
  );

  // Call onInit and onReady if it's a controller with lifecycle
  if (dependency is FlowLifeCycleMixin) {
    dependency.init();
    dependency.ready();
  }

  return dependency;
}