addSingleton<T extends Object> static method
void
addSingleton<T extends Object>(
- T instance
Registers an already existing instance as a Singleton
Useful for pre-configured objects or third-party dependencies initialized
asynchronously during app startup (e.g., SharedPreferences).
Throws an IonLocatorDuplicateRegistrationException if the type is already registered.
Implementation
static void addSingleton<T extends Object>(T instance) {
if (_factories.containsKey(T)) {
throw IonLocatorDuplicateRegistrationException(T);
}
_singletons[T] = instance;
_factories[T] = () => _singletons[T]!;
}