has<T> method

  1. @override
bool has<T>([
  1. String? context
])
override

Checks if a service is registered.

Verifies whether a binding or instance exists for the specified type, optionally within a specific context.

T - The type to check context - Optional context to check within Returns true if the service is registered

Implementation

@override
bool has<T>([String? context]) {
  if (context != null) {
    return _contextualBindings[context]?.containsKey(T) ?? false;
  }

  return _bindings.containsKey(T) || _instances.containsKey(T);
}