| Index: src/tests/site/code/futures.dart
|
| diff --git a/src/tests/site/code/futures.dart b/src/tests/site/code/futures.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5e0328787d414e3575b81c8cf2887f0d862e259b
|
| --- /dev/null
|
| +++ b/src/tests/site/code/futures.dart
|
| @@ -0,0 +1,18 @@
|
| +import 'dart:io';
|
| +import 'dart:async';
|
| +
|
| +void printDailyNewsDigest() {
|
| + File file = new File('dailyNewsDigest.txt');
|
| + file.readAsString() // readAsString() returns a Future.
|
| + .then((content) { // Specifies what to do if the Future completes successfully.
|
| + print(content); // Executes when the file has been successfully read.
|
| + })
|
| + .catchError((error) { // Specifies error handling code.
|
| + print("Sorry, no news today. Here's why:\n");
|
| + print('$error');
|
| + });
|
| +}
|
| +
|
| +main() {
|
| + printDailyNewsDigest();
|
| +}
|
|
|