I have two Future functions which I run asynchronously:
List<Future<bool>> jobs = [];
jobs.add(asyncFunction1());
jobs.add(asyncFunction2());
jobsResults = await Future.wait(jobs);
If asyncFunction1 returns false - I want to finish current procedure (for not to wait asyncFunction2). How to do it?
There isn't a standard way of doing this but a "hacky" way would be to have the functions throw errors if false. You could then utilize the
eagerError=True(parameter for Future.wait). That will return immediately on the first error received.Docs: https://api.dart.dev/stable/3.3.1/dart-async/Future/wait.html