Skip to content

Instantly share code, notes, and snippets.

@raveesh-me
Created February 22, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raveesh-me/4e258a941b03c5a94350ed2c29fd1525 to your computer and use it in GitHub Desktop.
Save raveesh-me/4e258a941b03c5a94350ed2c29fd1525 to your computer and use it in GitHub Desktop.
Multiple Futures
void main() async {
List<String> strings = [
'jgjjhga',
'tyuyua',
'afghf',
'dsfsd',
'trrt',
'zxczx',
'a',
'asd',
'a',
'sd'
];
List<int> hashCodes = await Future.wait(strings.map((string) {
return getHash(string);
}));
print(hashCodes);
}
Future<int> getHash(String string) async =>
await Future.delayed(Duration(seconds: 2), () {
return string.hashCode;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment