registerEagerSingleton<T> abstract method

void registerEagerSingleton<T>(
  1. AsyncFactory<T> factory, {
  2. AsyncPostCreate<T>? onCreate,
  3. String? name,
})

Registers an eager singleton that is resolved immediately during the build phase.

The factory is executed during build(), and the resulting instance is stored as a regular instance in the container. After build, these services can be accessed normally via Injector.get.

Use this for services that must be initialized early, such as configuration loaders, database connections, or core infrastructure.

Implementation

void registerEagerSingleton<T>(
  AsyncFactory<T> factory, {
  AsyncPostCreate<T>? onCreate,
  String? name,
});