delete<S> method

Future<bool> delete<S>({
  1. String? tag,
  2. bool force = false,
})

Deletes a registered dependency.

Implementation

Future<bool> delete<S>({String? tag, bool force = false}) async {
  final key = _getKey(S, tag);
  if (!_factories.containsKey(key)) return false;
  final dep = _factories[key]!;
  if (dep.permanent && !force) return false;

  final instance = dep.dependency;
  if (instance is GetLifeCycleMixin) {
    instance.onDelete();
  }
  _factories.remove(key);
  return true;
}