Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created May 9, 2019 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Code-Hex/44d0f9791a0bcc93ab62529b695dd7d7 to your computer and use it in GitHub Desktop.
Save Code-Hex/44d0f9791a0bcc93ab62529b695dd7d7 to your computer and use it in GitHub Desktop.
dart async sample
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