Skip to content

Instantly share code, notes, and snippets.

@redcatsec
Created March 25, 2020 10:03
Show Gist options
  • Save redcatsec/72217895c68e6de5e7aa5c3107f23a39 to your computer and use it in GitHub Desktop.
Save redcatsec/72217895c68e6de5e7aa5c3107f23a39 to your computer and use it in GitHub Desktop.
List<Future<String>> futuresList = new List<Future<String>>();
List<String> blogsList = ["1", "2", "3", "4", "5", "6"];
for (final blog in blogsList) {
if (blog == "2") {
futuresList.add(Future<String>.error('error').catchError((e) => e));
} else {
futuresList.add(Future.value(blog));
}
}
try {
List<String> responses = await Future.wait(futuresList);
print(responses);
} catch (e) {
print("Futures list error: " + e.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment