Skip to content
Snippets Groups Projects
Commit fb5139f6 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

fix: snackbar sucess messages

parent a71f637d
No related branches found
No related tags found
1 merge request!14Clhp map
......@@ -191,8 +191,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
child: const Text("Export JSON"),
onPressed: () {
Navigator.of(context).pop();
// Show progress indicator
// Close bottom sheet before displaying progress bar
showProgressIndicator(context);
},
......@@ -294,6 +293,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
}
}
// Saves all measurements to a file on the users mobile device
Future<void> _exportIceData() async {
final directory = await getExternalStorageDirectory();
final file = File('${directory?.path}/ice_data_$selectedLake.json');
......@@ -306,7 +306,6 @@ Future<void> _exportIceData() async {
}
// Display a progress indicator while JSON data is being downloaded
void showProgressIndicator(BuildContext context) {
BuildContext? dialogContext;
......@@ -333,9 +332,8 @@ void showProgressIndicator(BuildContext context) {
);
// Ensure that the progress indicator runs for at lest 1 second
// before exporting the data
Future.delayed(const Duration(milliseconds: 1000), () {
try {
Future.delayed(const Duration(seconds: 1), () {
try { // Download JSON data
_exportIceData();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Downloaded ice data as JSON')),
......@@ -349,6 +347,7 @@ void showProgressIndicator(BuildContext context) {
// Add 2 second delay before closing the dialog
Future.delayed(const Duration(seconds: 2), () {
Navigator.of(dialogContext!).pop();
Navigator.of(context).pop();
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment