mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
feat: add oauth2 credential file handling
This commit is contained in:
@@ -34,8 +34,9 @@ Future<String?> getFileDownloadpath(String? name, String? ext) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String?> getDocumentsDirectoryFilePath(String name, String? ext) async {
|
||||
final Directory tempDir = await getApplicationDocumentsDirectory();
|
||||
Future<String?> getApplicationSupportDirectoryFilePath(
|
||||
String name, String? ext) async {
|
||||
final Directory tempDir = await getApplicationSupportDirectory();
|
||||
name = name;
|
||||
ext = (ext != null) ? ".$ext" : "";
|
||||
String path = '${tempDir.path}/$name$ext';
|
||||
@@ -73,3 +74,28 @@ Future<XFile?> pickFile() async {
|
||||
XFile? pickedResult = await openFile();
|
||||
return pickedResult;
|
||||
}
|
||||
|
||||
Future<File?> loadFileFromPath(String filePath) async {
|
||||
try {
|
||||
final file = File(filePath);
|
||||
if (!await file.exists()) {
|
||||
return null;
|
||||
}
|
||||
return file;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deleteFileFromPath(String filePath) async {
|
||||
try {
|
||||
final file = File(filePath);
|
||||
if (await file.exists()) {
|
||||
await file.delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user