resolveAllKeys method

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

Resolve all MapEntry keys.

Implementation

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

  var futureKeys = <FutureOr<K>>[];
  var values = <V>[];

  for (var e in self) {
    futureKeys.add(e.key);
    values.add(e.value);
  }

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