Skip to content

Instantly share code, notes, and snippets.

@abbondanza
Last active November 19, 2021 18:10
Show Gist options
  • Save abbondanza/6c099a598a2fbfcc6db45da871bcec02 to your computer and use it in GitHub Desktop.
Save abbondanza/6c099a598a2fbfcc6db45da871bcec02 to your computer and use it in GitHub Desktop.
Async Dart
void main() async {
final delayed3 = Future.delayed(
const Duration(seconds: 3),
() => '3',
);
final delayed2 = Future.delayed(
const Duration(seconds: 2),
() => '2',
);
final delayed1 = Future.delayed(
const Duration(seconds: 1),
() => '1',
);
await Future.wait([
delayed3.then(print),
delayed2.then(print),
delayed1.then(print)
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment