ScopeKey<T> class
The only purpose of ScopeKeys is to be globally unique so that they can be used to uniquely identify injected values. ScopeKeys are opaque – you are not supposed to read any other information from them except t heir identity.
You must NOT extend or implement this class.
The debugName
is only used in error messages. We recommend that
you use a debugName of the form:
package_name.library_name.variableName
If a key is created with a default value, it will be returned by use
when no value was provided for this key. null
is a valid default value,
provided the T
is nullable (e.g. String?), and is distinct from no value.
The type argument T
is used to infer the return type of use.
ScopeKey<int> countKey = ScopeKey<int>(0);
ScopeKey<int> countKey = ScopeKey.withDefault<int>(0);
- Annotations
-
- @sealed
Constructors
- ScopeKey([String? debugName])
- Create a ScopeKey with a specific type.
- ScopeKey.withDefault(T defaultValue, [String? debugName])
- Create a ScopeKey that provides a default value if the key has not been added to the scope.
Properties
- hasDefault → bool
-
Returns true if the key was created with a default value.
A default has three states
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
testCast(
dynamic v) → T - test if the keys value is of type T.
-
testFunctionCast(
dynamic v) → T Function() - test if the keys function returns a value of type T.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited