Created
December 21, 2020 22:37
-
-
Save ridhoperdana/36188c7c2729a609a0b16f8429309dd2 to your computer and use it in GitHub Desktop.
example of async and standard function 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
| Future<String> asyncFunction(int functionID) async { | |
| return 'This will be run asynchronously $functionID'; | |
| } | |
| String standardFunction(int functionID) { | |
| return 'This will be run synchronously $functionID'; | |
| } | |
| void startFunction() { | |
| for (int i = 0; i < 10; i++) { | |
| asyncFunction(i).then((value) => {print(value)}); | |
| } | |
| print(standardFunction(100)); | |
| } | |
| void main() { | |
| startFunction(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment