You need to adapt each of your Future<T>
s to a common type of Future
. You could use Future<void>
and assign the results instead of relying on return values:
late List<Foo> foos;
late List<Bar> bars;
late List<FooBars> foobars;
await Future.wait<void>([
downloader.getFoos().then((result) => foos = result),
downloader.getBars().then((result) => bars = result),
downloader.getFooBars().then((result) => foobars = result),
]);
processData(foos, bars, foobars);
Or if you prefer await
to .then()
, the Future.wait
call could be:
await Future.wait<void>([
(() async => foos = await downloader.getFoos())(),
(() async => bars = await downloader.getBars())(),
(() async => foobars = await downloader.getFooBars())(),
]);