Created
March 25, 2020 10:03
-
-
Save redcatsec/72217895c68e6de5e7aa5c3107f23a39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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