resolveAllValues method

FutureOr<Iterable<MapEntry<K, V>>> resolveAllValues()

Resolve all MapEntry values.

Implementation

FutureOr<Iterable<MapEntry<K, V>>> resolveAllValues() {
  var self = this;
  if (self is Iterable<MapEntry<K, V>> && _isNotFuture(V)) {
    return self;
  }

  var keys = <K>[];
  var futureValues = <FutureOr<V>>[];

  for (var e in self) {
    keys.add(e.key);
    futureValues.add(e.value);
  }

  return futureValues.resolveAllJoined((values) {
    var entries = List.generate(values.length, (i) {
      var k = keys[i];
      var v = values[i];
      return MapEntry(k, v);
    });
    return entries;
  });
}