Skip to content

Instantly share code, notes, and snippets.

@ipondroid
Created October 24, 2019 08:20
Show Gist options
  • Save ipondroid/121fbf91f5eb6f728a1c79e1222ecf45 to your computer and use it in GitHub Desktop.
Save ipondroid/121fbf91f5eb6f728a1c79e1222ecf45 to your computer and use it in GitHub Desktop.
void future_wait(String url1, String url2) {
Future.wait([
http.get(url1),
http.get(url2),
Future.error('Future.error()'),
],
cleanUp: (value) { print('CleanUp() : ${value?.statusCode}'); }
).then((value) {
for (var f in value) {
print('statusCode: ${f?.statusCode}');
}
}).catchError((error) { print('error : $error'); });
}
// output
// CleanUp() : 200
// CleanUp() : 200
// error : Future.error()
// ouput
// statusCode: 200
// statusCode: 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment