value<T> method

void value<T>(
  1. ScopeKey<T> key,
  2. T value
)

Injects value into the Scope.

The value can be retrieve by calling use from anywhere within the action method provided to runSync

Scope()
  ..value<int>(ageKey, 18)
  ..value<int>(heightKey, getHeight())
  ..run(() {}

Implementation

void value<T>(ScopeKey<T> key, T value) {
  _checkDuplicateKey(key);
  _provided.putIfAbsent(key, () => value);
}