Last active
December 8, 2019 12:32
-
-
Save JaveedIshaq/1332c33b4ced6804a12815c654cf9a84 to your computer and use it in GitHub Desktop.
Future-async-await-in-dart.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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