-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.dart
29 lines (26 loc) · 786 Bytes
/
reader.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import 'dart:convert';
import 'dart:io';
class Reader {
static Future<String> getTodoFile() async {
String todoFilePath = "${Directory.current.path}/todo.txt";
File todoFile = File(todoFilePath);
if (!await todoFile.exists()) {
print("ERROR: 'todo.txt' not found");
exit(1);
}
String content = await todoFile.readAsString();
return content;
}
static Future<Map<String, dynamic>> getConfigFile() async {
String path = "todo.json";
File jsonFile = File(path);
if (!await jsonFile.exists()) {
print(
"ERROR: Configuration file 'todo.json' not found on project root folder");
exit(1);
}
Map<String, dynamic> jsonDecoded =
jsonDecode(await jsonFile.readAsString());
return jsonDecoded;
}
}