resolveAllEntries method

FutureOr<Map<K, V>> resolveAllEntries()

Resolve all Map entries.

Implementation

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

  var futureKeys = keys.toList(growable: false);
  var futureValues = keys.map((k) => this[k]!).toList(growable: false);

  return futureKeys.resolveAllJoined((keys) {
    return futureValues.resolveAllJoined((values) {
      var entries = List.generate(values.length, (i) {
        var k = keys[i];
        var v = values[i];
        return MapEntry(k, v);
      });
      return Map<K, V>.fromEntries(entries);
    });
  });
}