mirror of
https://github.com/foss42/apidash.git
synced 2025-05-22 08:46:33 +08:00
saveCollection Util
This commit is contained in:
20
lib/common/utils.dart
Normal file
20
lib/common/utils.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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