OLD | NEW |
---|---|
(Empty) | |
1 import 'dart:io'; | |
2 import 'dart:async'; | |
3 | |
4 void printDailyNewsDigest() { | |
5 File file = new File('dailyNewsDigest.txt'); | |
6 file.readAsString() // readAsString() returns a Future. | |
7 .then((content) => print(content)) // Handle successful completion. | |
8 .catchError((error) => // Handle failure. | |
9 print("Sorry, no news today. Here's why:\n$error")); | |
10 } | |
11 | |
12 main() { | |
13 printDailyNewsDigest(); | |
14 } | |
OLD | NEW |