I am trying to delete internal storage file into Flutter(Android). But It show error like this
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot delete file, path = '/storage/emulated/0/Pictures/Image Description (1).jpg' (OS Error: No such file or directory, errno = 2)
And I also check exitance of the file before deleting. Here is my code to delete file.
await Future.forEach(_selectedFile, (element) async {
if (await element?.exists() ?? false) {
await element?.delete(); // I got error in this line
}
});
I added all required permission to read and write internal storage.
Anyone have idea how to resolve it?
You can try this snippet: