Flutter, dart and Visual Studio. Android Devices.
After saving a file and reading it back to ensure all went OK I can't find the file, so it can't be emailed or viewed at all.
How can I save it so the user can see the file, so they can read it, or email it etc.
Thanks
class SaveJson {
SaveJson();
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<File> get _localFile async {
final path = await _localPath;
final file = File('${path}/macf.txt');
return file;
}
Future<File> writeJson(String data) async {
final file = await _localFile;
return file.writeAsString(data);
}
read() async {
try {
final directory = await getApplicationDocumentsDirectory();
final file = File('${directory.path}/macf.txt');
String text = await file.readAsString();
print(text);
} catch (e) {
print("Couldn't read file");
}
}
}