ServiceLocator class

Tiny service locator that provides a global access point to services

Constructors

ServiceLocator()
Singleton instance of ServiceLocator
factory

Properties

current ServiceContainer
Currently active scope (ServiceContainer).
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add<T>(T factory(), {String? tag, bool lazy = false, bool singleton = true}) → void
Register a service in the current scope
clear() → void
Clear all scopes
contains<T>({String? tag}) bool
Whether this container contains the service
get<T>({String? tag}) → T
Lookup a service in the current scope
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pop() → void
Remove the current scope and remove it from the stack
popUntil(String name) → void
Call pop repeatedly until the name of the current scope is the same as name.
push({String? name}) → void
Create a new scope and put it at the end of the stack
remove<T>({String? tag}) bool
Remove a service in the current scope
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

rootName String
Name of the root scope
final