resolveAllNullable method

FutureOr<List<T?>> resolveAllNullable()

Resolve all elements.

Implementation

FutureOr<List<T?>> resolveAllNullable() {
  var self = this;

  if (_isNotFuture(T)) {
    if (self is List<T>) {
      return self;
    } else if (self is List<T?>) {
      return self.toList();
    } else if (self is Iterable<T>) {
      return self.toList();
    } else if (self is Iterable<T?>) {
      return self.toList();
    }
  }

  var all = allAsList;
  if (all.isEmpty) return <T>[];

  if (all.isAllResolved) {
    return all.cast<T?>().toList();
  } else {
    return Future.wait<T?>(all.asFutures).then((values) {
      return values.toList();
    });
  }
}