Created
May 9, 2019 03:29
-
-
Save Code-Hex/44d0f9791a0bcc93ab62529b695dd7d7 to your computer and use it in GitHub Desktop.
dart async sample
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
void main() async { | |
print(new DateTime.now()); | |
String tm = await delayedTime(); | |
print(tm); | |
} | |
Future<String> delayedTime() async { | |
Duration oneSecond = new Duration(seconds: 2); | |
return new Future.delayed(oneSecond, () { | |
return new DateTime.now().toString(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment