Created
October 24, 2019 08:19
-
-
Save ipondroid/09d7cb218134410c4482168d190f3656 to your computer and use it in GitHub Desktop.
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 future_constructor_delayed() { | |
| Future.delayed( | |
| Duration(seconds: 3), | |
| () => 'Future.delayed(3 secs) done') | |
| .then((value) { print('$value'); }) | |
| .whenComplete( | |
| () { print('Future.delayed(3 secs) completed'); }); | |
| Future.delayed( | |
| Duration(seconds: 10), | |
| () => 'Future.delayed(10 secs) done') | |
| .timeout(Duration(seconds: 5)) | |
| .whenComplete( | |
| () { print('Future.delayed(10 secs) completed'); }) | |
| .then((value) { print('$value'); }) | |
| .catchError((error) { print('error $error'); }); | |
| } | |
| // output: | |
| // Future.delayed(3 secs) done | |
| // Future.delayed(3 secs) completed | |
| // Future.delayed(10 secs) completed | |
| // error TimeoutException after 0:00:05.000000: Future not completed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment