ninjiacoder
ninjiacoder

Reputation: 81

The file path changes after flutter run or update the app

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.

Upvotes: 4

Views: 2082

Answers (1)

ninjiacoder
ninjiacoder

Reputation: 81

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

Upvotes: 2

Related Questions