I’m trying to build an app to sync a folder on my mobile with Google Drive. My sync logic involves hashing all the files and storing them. However, when I run the following function, it returns a fileCount of 0.
Things I’ve Done:
- The app has read, write, and manage permissions for Android.
- The folder input is correct, and it contains files like images and PDFs.
import 'dart:io';
Future<int> getFolderHash(Directory folder) async {
try {
if (await folder.exists()) {
Get the list of all files and directories recursively
List<FileSystemEntity> entities = folder.listSync(recursive: true);
print(await folder.list().toList());
int fileCount = entities.whereType<File>().length;
print(entities);
return fileCount;
else {
return 0;
}
} catch (e) {
print('Error: $e');
return 0;
}
}
New contributor
k9 player is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.