ServiceLocator class
Service locator for dependency injection.
Supports:
- Singleton instances and factory functions
- Type-based lookup (default)
- Key-based lookup for multiple instances of same type
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get<
T extends Object> ({Symbol? key}) → T - Get instance or create from factory.
-
isRegistered<
T extends Object> ({Symbol? key}) → bool - Check if a type (and optional key) is registered.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register<
T extends Object> (T instance, {Symbol? key}) → void - Register a singleton instance.
-
registerFactory<
T extends Object> (T factory(), {Symbol? key}) → void - Register a factory function.
-
reset(
) → void - Reset all registrations.
-
toString(
) → String -
A string representation of this object.
inherited
-
unregister<
T extends Object> ({Symbol? key}) → void - Remove a registration.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited