put<T> static method
Registers a singleton instance in the dependency store.
If a dependency with the same type and tag already exists, it will be overwritten with a warning logged.
Parameters:
dependency: The instance to registertag: Optional identifier for multiple instances of the same type
Returns the registered instance.
Example:
final controller = Dependency.put(MyController());
// With tag
Dependency.put(AuthService(), tag: 'primary');
Implementation
static T put<T>(
T dependency, {
String? tag,
}) {
final key = _getKey(dependency.runtimeType, tag: tag);
if (_dependencyStore[key] != null) {
Logger.warn(
'Dependency of type ${dependency.runtimeType} is being overwritten',
tag: 'Dependency',
);
}
_dependencyStore[key] = dependency;
// // Note: fenix mode for put() is currently not fully implemented
// // For phoenix behavior with recreation, use lazyPut() instead
// if (fenix) {
// // Reserved for future implementation
// }
return _dependencyStore[key];
}