registerAlias method

  1. @override
void registerAlias(
  1. String name,
  2. String alias
)
override

Registers an alias for an existing name in the registry.

Associates a new alias with an existing name, allowing the object registered under name to be accessed using the alias as well.

Parameters:

  • name: The primary name that already exists in the registry
  • alias: The alternative name to register for the primary name

Throws:

Example:

final registry = MyAliasRegistry();

// First register a primary name
registry.registerPrimary('emailService');

// Then register aliases for it
registry.registerAlias('emailService', 'mailService');
registry.registerAlias('emailService', 'smtpService');

// Now the service can be accessed by any of these names
final service1 = registry.get('emailService');
final service2 = registry.get('mailService'); // Same as service1
final service3 = registry.get('smtpService'); // Same as service1

Implementation

@override
void registerAlias(String name, String alias) => podFactory.registerAlias(name, alias);