Skip to content

Instantly share code, notes, and snippets.

@JaveedIshaq
Last active December 8, 2019 12:32
Show Gist options
  • Save JaveedIshaq/1332c33b4ced6804a12815c654cf9a84 to your computer and use it in GitHub Desktop.
Save JaveedIshaq/1332c33b4ced6804a12815c654cf9a84 to your computer and use it in GitHub Desktop.
Future-async-await-in-dart.dart
import 'dart:io';
void main() {
taskRunner();
}
void taskRunner() async {
funtionOne();
String result = await funtionTwo();
funtionThree(result);
}
void funtionOne() {
print("A print from Function One");
}
Future funtionTwo() async {
Duration duration3Seconds = Duration(seconds: 3);
String result;
await Future.delayed(duration3Seconds, () {
result ="this is the Future(Promise)";
print("A print from Function Two after Delayed Future");
});
return result;
}
void funtionThree(String task2Data) {
print("A print from Function Three $task2Data");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment