sequence<T> method

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

Injects a generated sequence of values into the Scope from a factory method.

The sequence's factory method may use values, singles and other sequences registered within the SAME Scope.

The sequence's factory method is called each time use for key is called.

The difference between single and sequence is that for a single the factory method is only called once where as the sequences factory method is called each time use for the sequence's key is called.

The sequence factory method is NOT called when the runSync method is called.

Scope()
  ..sequence<int>(ageKey, () => genRandomInt())
  ..run(() {}

Implementation

void sequence<T>(ScopeKey<T> key, T Function() factory) {
  _checkDuplicateKey(key);
  value<dynamic>(key, factory);
}