feat: add oauth2 credential file handling

This commit is contained in:
Udhay-Adithya
2025-07-21 23:07:34 +05:30
parent 4e924fc946
commit f458d00341
6 changed files with 122 additions and 32 deletions

View File

@@ -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;
}
}