getModule<T extends EasyModule> static method

  1. @internal
T? getModule<T extends EasyModule>()

Gets a module instance of type T if it exists.

Returns null if the module is not found. If the module exists but its injector hasn't been committed yet, this method will commit it before returning.

Note: This method is internal and should not be used outside the module manager. Use EasyDI.get instead to retrieve dependencies.

Implementation

@internal
static T? getModule<T extends EasyModule>() {
  final module = _modules[T] as T?;
  if (module?.injector case CustomAutoInjector injector when !injector.committed) {
    injector.commit();
  }
  return module;
}