Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created May 9, 2019 03:29
Show Gist options
  • Select an option

  • Save Code-Hex/44d0f9791a0bcc93ab62529b695dd7d7 to your computer and use it in GitHub Desktop.

Select an option

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