mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
|
|
import 'package:flutter/foundation.dart';
|
||
|
|
import 'package:flutter/services.dart';
|
||
|
|
|
||
|
|
class LocalFilesManager {
|
||
|
|
static const MethodChannel _channel = MethodChannel('file_trash');
|
||
|
|
|
||
|
|
static Future<bool> moveToTrash(String fileName) async {
|
||
|
|
try {
|
||
|
|
final bool success =
|
||
|
|
await _channel.invokeMethod('moveToTrash', {'fileName': fileName});
|
||
|
|
return success;
|
||
|
|
} on PlatformException catch (e) {
|
||
|
|
debugPrint('Error moving to trash: ${e.message}');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
static Future<bool> restoreFromTrash(String fileName) async {
|
||
|
|
try {
|
||
|
|
final bool success = await _channel
|
||
|
|
.invokeMethod('restoreFromTrash', {'fileName': fileName});
|
||
|
|
return success;
|
||
|
|
} on PlatformException catch (e) {
|
||
|
|
debugPrint('Error restoring file: ${e.message}');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
static Future<bool> requestManageStoragePermission() async {
|
||
|
|
try {
|
||
|
|
final bool success =
|
||
|
|
await _channel.invokeMethod('requestManageStoragePermission');
|
||
|
|
return success;
|
||
|
|
} on PlatformException catch (e) {
|
||
|
|
debugPrint('Error requesting permission: ${e.message}');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|