resolveAllValues method

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

Resolve all Map values (non nullable).

Implementation

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

  var keys = this.keys.toList(growable: false);
  var futureValues =
      keys.map((k) => this[k]!).cast<FutureOr<V>>().toList(growable: false);

  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);
  });
}