get<T> static method

T? get<T>()

Provides a way to access a pre-registered instance of type T.

Implementation

static T? get<T>() {
  final instance = _serviceMap[getName<T>()]?.singleton as T?;
  if (instance == null) {
    final message = '${T.toString()} is not registered.';
    if (config.throwOnUnregisered)
      throw Exception(message);
    else
      print(message);
  }
  return instance;
}