Skip to content

Instantly share code, notes, and snippets.

@piscis
Last active April 26, 2019 11:13
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 piscis/412ed128bfafe2f08fa81b820f56f9ba to your computer and use it in GitHub Desktop.
Save piscis/412ed128bfafe2f08fa81b820f56f9ba to your computer and use it in GitHub Desktop.
import 'dart:async';
// This is a workaround because sleep from dart:io breaks DartPad instead we're using a Future
Future sleep1() {
return new Future.delayed(const Duration(seconds: 1), () => "1");
}
void main() {
do_long_running_fancy_stuff() {
print("FANCY STUFF DONE1");
sleep1();
print("FANCY STUFF DONE2");
sleep1();
print("NOW IM DONE");
}
Future foobar() {
return new Future(() {
do_long_running_fancy_stuff();
});
}
foobar();
print("I'M DONE ... but wait ...");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment