added error catch to saveFile
This commit is contained in:
@@ -331,10 +331,20 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
}
|
}
|
||||||
await prefs.setString('saveDir', selectedDirectory);
|
await prefs.setString('saveDir', selectedDirectory);
|
||||||
|
|
||||||
File file = File('$selectedDirectory/cam-${id.text}.txt');
|
// ignore: use_build_context_synchronously
|
||||||
|
File file = File('$selectedDirectory/${AppLocalizations.of(context)!.justplace}-${standortC.text}.txt');
|
||||||
await file.writeAsString(jsonPlace);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
await file.writeAsString(jsonPlace);
|
||||||
|
} catch (e) {
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
Navigator.pop(context);
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
content: Text(AppLocalizations.of(context)!.savefilefailed)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
||||||
|
|||||||
@@ -88,5 +88,7 @@
|
|||||||
"sendfile": "Datei zum Server senden",
|
"sendfile": "Datei zum Server senden",
|
||||||
"pickfile": "Datei auswählen",
|
"pickfile": "Datei auswählen",
|
||||||
"placedata": "Standortdaten",
|
"placedata": "Standortdaten",
|
||||||
"sent": "Gesendet"
|
"sent": "Gesendet",
|
||||||
|
"savefilefailed": "Fehler. Bitte nochmal versuchen",
|
||||||
|
"justplace": "Standort"
|
||||||
}
|
}
|
||||||
@@ -427,6 +427,16 @@
|
|||||||
"sent": "Sent",
|
"sent": "Sent",
|
||||||
"@sent": {
|
"@sent": {
|
||||||
"description": "view data sent header"
|
"description": "view data sent header"
|
||||||
|
},
|
||||||
|
|
||||||
|
"savefilefailed": "Error. Please try again",
|
||||||
|
"@savefilefailed": {
|
||||||
|
"description": "save as file failed snackbar"
|
||||||
|
},
|
||||||
|
|
||||||
|
"justplace": "Place",
|
||||||
|
"@justplace": {
|
||||||
|
"description": "just the word place"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user