resolveAllValuesNullable method
Resolve all Map values that can be null
.
Implementation
FutureOr<Map<K, V?>> resolveAllValuesNullable() {
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.resolveAllNullable().resolveMapped((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);
});
}