ServiceRegistry class
An object that manages the cleanup of service objects when an application is stopped.
You register objects with the registry to provide automatic cleanup of service objects. When an application is stopped (typically during testing), all registered objects are destroyed in an object-specific way.
Services that open ports will stop an application from stopping gracefully, so it is important that your application releases them when stopping.
There is one registry per isolate. The order in which registrations are shut down is undefined. close triggers shutdown and is automatically invoked by Application.stop.
Built-in aquedart types that open a stream, like PersistentStore, automatically register themselves when instantiated. If you are unsure whether an object has already been registered, you may re-register it - multiple registrations have no effect.
Constructors
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
-
close(
) → Future - Cleans up all registered objects.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register<
T> (T object, FutureOr onClose(T object)) → T -
Register
object
to be destroyed when your application is stopped. -
toString(
) → String -
A string representation of this object.
inherited
-
unregister(
dynamic object) → void - Removes an object from the registry.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultInstance → ServiceRegistry
-
final