I get (OS Error: No such file or directory, errno = 2) in Flutter when file.delete(). At the same file.exist() return true

Viewed 604

I am developing a Flutter app. I am trying to add a functionality to delete a file in device storage. When i initialize a file object with the path to the file, and run file.exist() i get true. But when i run file.delete() i get

(OS Error: No such file or directory, errno = 2)when file.delete(). At the same file.exist() return true!

I have these permissions in my manifest

  <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.STORAGE_INTERNAL" />

and

  <application
    android:requestLegacyExternalStorage="true"

And i am using permission_handler to ask for permission first.

Any idea?

0 Answers
Related