import 'dart:async'; import 'dart:io'; import 'package:path_provider/path_provider.dart'; class FileLoader { Future get _localPath async { final directory = await getApplicationDocumentsDirectory(); return directory.path; } Future get _localFile async { final path = await _localPath; return new File('$path/days.json'); } Future checkForFile() async { final file = await _localFile; return file.exists(); } Future writeFile(String data) async { final file = await _localFile; return file.writeAsString(data); } Future readFile() async { try { final file = await _localFile; String contents = await file.readAsString(); return contents; } catch (e) { throw OSError("File not found"); } } }