runAppLegacy<T extends Object> function

ComponentRef<T> runAppLegacy<T extends Object>(
  1. Type componentType, {
  2. List<Object> createInjectorFromProviders = const [],
  3. void initReflector()?,
})

Starts a new AngularDart application with componentType as the root.

This method is soft deprecated, and runApp is preferred as soon as initReflector is no longer needed in your application. Specifically, using this method enables the use of the following deprecated APIs:

  • ReflectiveInjector

... if neither your app nor your dependencies requires these APIs, it is recommended to switch to runApp instead, which has significant code-size and startup time benefits.

Implementation

ComponentRef<T> runAppLegacy<T extends Object>(
  Type componentType, {
  List<Object> createInjectorFromProviders = const [],
  void Function()? initReflector,
}) {
  assert(T == Object || T == componentType, 'Expected $componentType == $T');
  if (initReflector != null) {
    initReflector();
  }
  return runApp(
    unsafeCast(typeToFactory(componentType)),
    createInjector: (parent) {
      return ReflectiveInjector.resolveAndCreate(
        [
          createInjectorFromProviders,
        ],
        unsafeCast(parent),
      );
    },
  );
}