unbind<T> method

  1. @override
void unbind<T>([
  1. String? context
])
override

Removes a service registration.

Unbinds the specified type from the container, optionally within a specific context. Also removes any cached instances.

T - The type to unbind context - Optional context to unbind from

Implementation

@override
void unbind<T>([String? context]) {
  if (context != null) {
    _contextualBindings[context]?.remove(T);
  } else {
    _bindings.remove(T);
    _instances.remove(T);
    for (final ctx in _contextualBindings.keys) {
      _contextualBindings[ctx]?.remove(T);
    }
  }
}