Service class

Class-Annotation for defining services.

Services are modular components of the application which are independent from other services which aren't marked as dependencies. Dependencies can be declared via the constructor and further configured with annotations like @Named().

Example for declaring a Service:

@Service()
class ServiceA {
  Dependency dep;

  ServiceA(this.dep)
}

Services also have their own lifecycle consisting of a start and stop signals. If the service extends ServiceBase, both ServiceBase.start and ServiceBase.stop will be bound to these signals. The ServiceBase class can be used to further abstract services and create other abstract base classes. The terminal implementation of the service can further specify start and stop methods with the @Start and @Stop annotations. These methods must have no arguments and can either be a void or a Future.

Services can also define binding conditions, which must be met for the service to be marked eligible for registration. Conditions can be specified by annotating the implementing type with a const class implementing condition. One example for this is the Profile annotation.

Constructors

Service([Type? type])
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type Type?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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