25 lines
477 B
Dart
25 lines
477 B
Dart
|
library titama.io;
|
||
|
|
||
|
import 'dart:io';
|
||
|
import 'dart:convert';
|
||
|
|
||
|
import '../common/messages.dart';
|
||
|
|
||
|
/**
|
||
|
* Class for writing and loading the courses as JSON to a file.
|
||
|
*/
|
||
|
class TitamaIo {
|
||
|
|
||
|
final _filename = "./data.json";
|
||
|
|
||
|
/**
|
||
|
* Write courses as JSON in a file.k
|
||
|
* @param List<Courses> _course List of courses to save.
|
||
|
*/
|
||
|
writeJson(List<Course> _courses) async {
|
||
|
String _json = JSON.encode(_courses);
|
||
|
await new File(_filename).writeAsString(_json);
|
||
|
}
|
||
|
|
||
|
}
|