Reputation: 2187
Fallowing code include two Network Request which is running Asynchronous, I want to run them parallel and get their result to compare before moving to next code.
final failureOrGovernate = await getGovernateDataUsecase();
final failureOrArea = await getAreaDataUsecase();
Thank You, your comments and answers are highly appreciated.
Upvotes: 1
Views: 144
Reputation: 11994
You can wait on multiple futures in parallel with Future.wait()
final both = await Future.wait([getGovernateDataUsecase(), getAreaDataUsecase()]);
final failureOrGovernate = both[0];
final failureOrArea = both[1];
Upvotes: 5