addLazySingleton<T> method

  1. @override
void addLazySingleton<T>(
  1. Function constructor, {
  2. BindConfig<T>? config,
  3. String? key,
})
inherited

Register a LazySingleton instance. It will generate a single instance for the duration of the application, or until manually removed.
The object will be started only when requested the first time.

injector.addLazySingleton(MyController.new);

When [key] is provided this instance only can be found by key

Implementation

@override
void addLazySingleton<T>(
  Function constructor, {
  BindConfig<T>? config,
  String? key,
}) =>
    _add<T>(
      constructor,
      type: BindType.lazySingleton,
      config: config,
      key: key,
    );