Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The file path changes after flutter run or update the app

Tags:

flutter

I use method getApplicationDocumentsDirectory() in path_provider to get the image path.

However, when I flutter run or update my app in AppStore, the path got by getApplicationDocumentDirectory() will change and I can't get the image by the path stored before.

like image 584
ninjiacoder Avatar asked Oct 23 '25 18:10

ninjiacoder


1 Answers

Actually, it's easy to solve it.

I used the absolute path of the image so every time I rerun the app, the container id will change, so I cannot get the image with the previous path.

To solve it, you need to use relative path.

Relative Resource: https://github.com/flutter/flutter/issues/23957

like image 56
ninjiacoder Avatar answered Oct 26 '25 10:10

ninjiacoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!