resolveAllKeys method

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

Resolve all Map keys.

Implementation

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

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

  return futureKeys.resolveAllJoined((keys) {
    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);
  });
}