getKeyedService<T> method

T? getKeyedService<T>(
  1. Object? serviceKey
)

Get service of type T from the ServiceProvider.

Implementation

T? getKeyedService<T>(Object? serviceKey) {
  if (this is KeyedServiceProvider) {
    var service =
        (this as KeyedServiceProvider).getKeyedServiceFromType(T, serviceKey);
    if (service != null) {
      return service as T;
    }
    return null;
  }

  throw InvalidOperationException(
    message: 'This service provider doesn\'t support keyed services.',
  );
}