Created
February 22, 2020 13:33
-
-
Save raveesh-me/4e258a941b03c5a94350ed2c29fd1525 to your computer and use it in GitHub Desktop.
Multiple Futures
This file contains hidden or 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
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