mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Add save_utils.dart
This commit is contained in:
22
lib/utils/save_utils.dart
Normal file
22
lib/utils/save_utils.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/utils/utils.dart';
|
||||
import 'package:apidash/widgets/widgets.dart';
|
||||
|
||||
Future<void> saveCollection(
|
||||
Map<String, dynamic> 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));
|
||||
}
|
Reference in New Issue
Block a user