resolveStaticAndCreate method

  1. @experimental
ReflectiveInjector resolveStaticAndCreate(
  1. List<Object> providersOrLists,
  2. [Injector parent = const EmptyInjector()]

Creates a new Injector that resolves some Provider instances.

In particular, only the following provider types are now valid:

  • ValueProvider (or Provider(useValue: ...))
  • ExistingProvider (or Provider(useExisting: ...))
  • FactoryProvider (or Provider(useFactory: ...)) with deps provided.

Specifically, any providers that require looking up factory functions or argument information for factory functions at runtime are not supported since they would defeat the tree-shaking improvements of "runApp".

See for details.

Any other type of Provider will throw during creation in development mode and may fail unexpectedly in production mode. This is to allow eased migration towards the runApp API without entirely giving up the ability to use the dynamic nature of ReflectiveInjector.

WARNING: This is not intended to be a long-term API, and instead is an alternative to ReflectiveInjector.resolveAndCreate. It is greatly preferred to use or @GeneratedInjector for new usages.


static ReflectiveInjector resolveStaticAndCreate(
  List<Object> providersOrLists, [
  Injector parent = const EmptyInjector(),
]) {
  final flatProviders = _flattenProviders(providersOrLists);
  if (isDevMode) {
  return _RuntimeInjector(