resolveAllValidated method

Future<List<T>> resolveAllValidated(
  1. bool validate(
    1. T e
    ), {
  2. T? defaultValue,
})

Resolves this Futures and validates with validate.

Implementation

Future<List<T>> resolveAllValidated(bool Function(T e) validate,
    {T? defaultValue}) {
  if (isEmpty) {
    return Future.value(<T>[]);
  }

  return Future.wait(this).then((l) {
    return l.map((v) => validate(v) ? v : defaultValue as T).toList();
  });
}