delete<S> method

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

Delete registered Class Instance S (or tag) and, closes any open controllers DisposableInterface, cleans up the memory

/// Deletes the Instance<S>, cleaning the memory. Deletes the Instance<S>, cleaning the memory and closes any open controllers (DisposableInterface).

  • tag Optional "tag" used to register the Instance
  • key For internal usage, is the processed key used to register the Instance. don't use it unless you know what you are doing.
  • force Will delete an Instance even if marked as permanent.

Implementation

//  ///
//  /// - [tag] Optional "tag" used to register the Instance
//  /// - [key] For internal usage, is the processed key used to register
//  ///   the Instance. **don't use** it unless you know what you are doing.

/// Deletes the Instance<[S]>, cleaning the memory and closes any open
/// controllers (`DisposableInterface`).
///
/// - [tag] Optional "tag" used to register the Instance
/// - [key] For internal usage, is the processed key used to register
///   the Instance. **don't use** it unless you know what you are doing.
/// - [force] Will delete an Instance even if marked as `permanent`.
bool delete<S>({String? tag, String? key, bool force = false}) {
  final dep = key == null ? (_typeSingl[S]?[tag]) : _factoryForKey(key);
  if (dep == null) {
    return false;
  }
  if (key != null &&
      ((S != dynamic && dep.registeredType != S) ||
          (tag != null && dep.tag != tag))) {
    throw ArgumentError(
        'Dependency key does not match the supplied type/tag');
  }
  return _deleteFactory(dep, force: force);
}