Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: src/tests/site/code/futures.dart

Issue 22528003: update examples on homepage (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: fix comment Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+}

Powered by Google App Engine
This is Rietveld 408576698