Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save artem-zaitsev/82f36cbf0e6a3f94ddda0ba67b9fbab8 to your computer and use it in GitHub Desktop.
Save artem-zaitsev/82f36cbf0e6a3f94ddda0ba67b9fbab8 to your computer and use it in GitHub Desktop.
void main() {
awaited();
}
void syncFuture() {
print("hello first!");
Future((){
print("this is hello from future");
}).then((_) {
print("Future completed");
});
print("bye!");
for(var i=0;i<5;i++) {
print("busy work");
}
}
//// async / await ////
void awaited() async {
printA();
printB();
await printC("main");
await printD();
}
void printA(){
print("A");
}
void printB() async {
print("B started");
await printC("B");
print("end B");
}
void printC(String from) async {
print("C started from $from");
await Future((){
print("C running in future $from");
}).then((_){
print("Future completed");
});
print("end of C from $from");
}
void printD() async {
print("D");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment