wait property
Waits for futures in parallel.
Waits for all the futures in this record. Returns a record of the values, if all futures are successful.
The returned future is completed when all the futures have completed. If any of the futures do not complete, nor does the returned future.
If some futures complete with an error,
the returned future completes with a ParallelWaitError.
The ParallelWaitError.values is a record of the values of
successful futures, and null
for futures with errors.
The ParallelWaitError.errors is a record of the same shape,
with null
values for the successful futures
and an AsyncError with the error of futures
which completed with an error.
Implementation
Future<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> get wait {
@pragma('vm:awaiter-link')
final c = Completer<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>.sync();
final v1 = _FutureResult<T1>($1);
final v2 = _FutureResult<T2>($2);
final v3 = _FutureResult<T3>($3);
final v4 = _FutureResult<T4>($4);
final v5 = _FutureResult<T5>($5);
final v6 = _FutureResult<T6>($6);
final v7 = _FutureResult<T7>($7);
final v8 = _FutureResult<T8>($8);
final v9 = _FutureResult<T9>($9);
_FutureResult._waitAll([v1, v2, v3, v4, v5, v6, v7, v8, v9], (int errors) {
if (errors == 0) {
c.complete((
v1.value,
v2.value,
v3.value,
v4.value,
v5.value,
v6.value,
v7.value,
v8.value,
v9.value,
));
} else {
c.completeError(
ParallelWaitError(
(
v1.valueOrNull,
v2.valueOrNull,
v3.valueOrNull,
v4.valueOrNull,
v5.valueOrNull,
v6.valueOrNull,
v7.valueOrNull,
v8.valueOrNull,
v9.valueOrNull,
),
(
v1.errorOrNull,
v2.errorOrNull,
v3.errorOrNull,
v4.errorOrNull,
v5.errorOrNull,
v6.errorOrNull,
v7.errorOrNull,
v8.errorOrNull,
v9.errorOrNull,
),
errorCount: errors,
defaultError:
v1.errorOrNull ??
v2.errorOrNull ??
v3.errorOrNull ??
v4.errorOrNull ??
v5.errorOrNull ??
v6.errorOrNull ??
v7.errorOrNull ??
v8.errorOrNull ??
v9.errorOrNull,
),
);
}
});
return c.future;
}