resolveAndCreate static method

ReflectiveInjector resolveAndCreate(
  1. List<Object> providersOrLists, [
  2. Injector? parent
])

Creates a new Injector that resolves Provider instances at runtime.

This is an expensive operation without any sort of caching or optimizations that manually walks the nested providersOrLists, and uses a form of runtime reflection to figure out how to map the providers to runnable code.

Using this function can disable all tree-shaking for any @Injectable annotated function or class in your entire transitive application, and is provided for legacy compatibility only.

Implementation

static ReflectiveInjector resolveAndCreate(
  List<Object> providersOrLists, [
  Injector? parent,
]) {
  // Return the default implementation.
  final flatProviders = _flattenProviders(providersOrLists);
  if (isDevMode) {
    _assertProviders(flatProviders.providers.values);
    _assertProviders(flatProviders.multiProviders);
    _assertGlobalSingletonService(flatProviders.providers.values);
    _assertGlobalSingletonService(flatProviders.multiProviders);
  }
  return _RuntimeInjector(
    flatProviders.providers,
    flatProviders.multiProviders,
    parent,
    false,
  );
}