ServiceKey<T extends Object> class final

A typed name for distinguishing multiple implementations of the same type.

Most services can be resolved only by type:

final database = use<Database>();

Use a ServiceKey only when the same contract has multiple registrations:

const primaryDatabase = ServiceKey<Database>('primary');
const analyticsDatabase = ServiceKey<Database>('analytics');

Constructors

ServiceKey(String name)
const

Properties

hashCode int
The hash code for this object.
no setteroverride
name String
The logical name of this registration.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceType Type
The service type represented by this key.
no setter

Methods

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