Skip to content

Instantly share code, notes, and snippets.

@claireliu14
Last active June 27, 2019 07:55
Show Gist options
  • Save claireliu14/55229e8e2bb33644e0e132e9ef294521 to your computer and use it in GitHub Desktop.
Save claireliu14/55229e8e2bb33644e0e132e9ef294521 to your computer and use it in GitHub Desktop.
Sample of Future
import 'dart:async';
void main() {
getAJoke().then((value) {
print(value);
})
.whenComplete(() {
print('Complete');
})
.catchError((error) {
print('Error');
});
}
Future<String> getAJoke() {
return new Future<String>.delayed(
const Duration(seconds: 5), () {
return "This is a joke";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment