Context<R> class

A collection that holds contextual data (services/dependencies) required by effects.

Context uses a type-safe approach where services are identified by their type.

Properties

hashCode int
The hash code for this object.
no setteroverride
isEmpty bool
Returns true if this context is empty
no setter
isNotEmpty bool
Returns true if this context is not empty
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceTypes Iterable<Type>
Returns all service types in this context
no setter
size int
Returns the number of services in this context
no setter

Methods

add<T extends Object>(T service) Context<R>
Adds a service to this context, returning a new context
get<T extends Object>() → T
Gets a service from this context by its type
has<T extends Object>() bool
Checks if a service of the given type exists in this context
merge(Context other) Context<R>
Combines this context with another context Services from other will override services of the same type in this context
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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

Static Methods

empty() Context<Never>
Creates an empty context
of<T extends Object>(T service) Context<T>
Creates a context with a single service