Revert "Rename everything filcnaplo-related to refilc"
This reverts commit d1a9625d93.
This commit is contained in:
39
filcnaplo/lib/helpers/storage_helper.dart
Normal file
39
filcnaplo/lib/helpers/storage_helper.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
// ignore_for_file: avoid_print
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class StorageHelper {
|
||||
static Future<bool> write(String path, Uint8List data) async {
|
||||
try {
|
||||
if (await Permission.manageExternalStorage.request().isGranted) {
|
||||
await File(path).writeAsBytes(data);
|
||||
return true;
|
||||
} else {
|
||||
if (await Permission.storage.isPermanentlyDenied) {
|
||||
openAppSettings();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
print("ERROR: StorageHelper.write: $error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String> downloadsPath() async {
|
||||
String downloads;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
downloads = "/storage/self/primary/Download";
|
||||
} else {
|
||||
downloads = (await getTemporaryDirectory()).path;
|
||||
}
|
||||
|
||||
return downloads;
|
||||
// return (await getTemporaryDirectory()).path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user