registerSingle<T, R extends T> method
Register a singleton that returns the same instance on each resolution.
The singleton is scoped to this container. If a parent has a singleton with the same key, this registration shadows it for this scope and children.
Type Parameters:
T: The interface or base type to registerR: The concrete implementation (must extend or implementT)
Parameters:
locator: Factory function called once to create the singletonname: Optional name qualifier for named instances
Implementation
void registerSingle<T, R extends T>(SpotGetter<R> locator, {String? name}) {
final key = SpotKey<T>(T, name);
if (registry.containsKey(key) && logging) {
log.w('Overriding singleton in scope: $key with $R');
}
registry[key] = SpotService<T>(SpotType.singleton, locator as SpotGetter<T>, R);
if (logging) log.v('Registered singleton in scope: $key -> $R');
}