resolveAllNotNull method

FutureOr<List<T>> resolveAllNotNull()

Resolve all elements and select all non-null elements.

Implementation

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

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

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

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