diff --git a/lib/common/utils.dart b/lib/common/utils.dart new file mode 100644 index 00000000..8eaf2b2c --- /dev/null +++ b/lib/common/utils.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:apidash/utils/utils.dart'; +import 'package:apidash/widgets/widgets.dart'; + +Future saveCollection( + Map data, ScaffoldMessengerState sm) async { + var message = ""; + try { + var pth = await getFileDownloadpath(null, "har"); + if (pth != null) { + await saveFile(pth, jsonMapToBytes(data)); + var sp = getShortPath(pth); + message = 'Saved to $sp'; + } + } catch (e) { + message = "An error occurred while exporting."; + } + sm.hideCurrentSnackBar(); + sm.showSnackBar(getSnackBar(message, small: false)); +}