added error catch to saveFile
This commit is contained in:
@@ -331,14 +331,24 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
await prefs.setString('saveDir', selectedDirectory);
|
||||
|
||||
File file = File('$selectedDirectory/cam-${id.text}.txt');
|
||||
|
||||
await file.writeAsString(jsonPlace);
|
||||
// ignore: use_build_context_synchronously
|
||||
File file = File('$selectedDirectory/${AppLocalizations.of(context)!.justplace}-${standortC.text}.txt');
|
||||
|
||||
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
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
||||
|
||||
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
|
||||
@@ -88,5 +88,7 @@
|
||||
"sendfile": "Datei zum Server senden",
|
||||
"pickfile": "Datei auswählen",
|
||||
"placedata": "Standortdaten",
|
||||
"sent": "Gesendet"
|
||||
"sent": "Gesendet",
|
||||
"savefilefailed": "Fehler. Bitte nochmal versuchen",
|
||||
"justplace": "Standort"
|
||||
}
|
||||
@@ -427,6 +427,16 @@
|
||||
"sent": "Sent",
|
||||
"@sent": {
|
||||
"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