Created
March 15, 2020 16:13
-
-
Save samramez/017e03341e5d3dfdaf159898fc4eabe7 to your computer and use it in GitHub Desktop.
Simple practice code for using Dart Future object.
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
import 'dart:async'; | |
void main() { | |
Future<int>.delayed(Duration(seconds: 3), () { | |
return 100; | |
}).then((value) { | |
print(value); | |
}).then((value) { | |
throw Exception(); | |
}).catchError((exception) { | |
print("exception happened"); | |
}).whenComplete(() { | |
print("everything is now complete!"); | |
}).then((value) { | |
print("I get printed after everything was completed :)"); | |
}); | |
print("waiting.."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to test this sample code, just go to https://dartpad.dev/ and copy-paste all the code from this Gist