Created
August 11, 2020 09:54
-
-
Save cankush625/7b2fd754727dfe8e61fc975b2f176ccd to your computer and use it in GitHub Desktop.
Asynchronous programming in dart
This file contains hidden or 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
| void main() => myTasks(); | |
| myTasks() { | |
| printMessage(); | |
| acknowledgeFileUpload(); | |
| thankyouMessage(); | |
| } | |
| void printMessage() { | |
| print("Task Started"); | |
| } | |
| Future<int> uploadFileToTheServer() async { | |
| print("Uploading file..."); | |
| Duration d = new Duration(seconds: 10); | |
| await Future.delayed(d); | |
| return 1; | |
| } | |
| void acknowledgeFileUpload() { | |
| Future<int> result = uploadFileToTheServer(); | |
| String res = result.toString(); | |
| if (res.compareTo("1") == 1) { | |
| print("success"); | |
| } else { | |
| print("failed"); | |
| } | |
| } | |
| void thankyouMessage() { | |
| print("Thanks for using this platform"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment