Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Multiple calls to getImage return the same file #24

Open
Gloumy opened this issue Feb 12, 2020 · 3 comments
Open

[iOS] Multiple calls to getImage return the same file #24

Gloumy opened this issue Feb 12, 2020 · 3 comments

Comments

@Gloumy
Copy link

Gloumy commented Feb 12, 2020

Hello,
I'm getting a weird behavior on iOS (Android is fine though). I'm using image_picker to get images either from camera or gallery, and the user is allowed to call that repeatedly.
It works fine for the first picture, but when adding another the picture displayed is the first one.
I'm then passing each file to an array in a provider state, and when i do my http call to post them to my backend only the last picture is returned for each file.

getImage()
Future getImage(source) async { var picture = await ImagePicker.pickImage(source: source); if (picture != null) { picture = await FlutterExifRotation.rotateAndSaveImage(path: picture.path); Provider.of<NewDiscussionState>(context).addPicture(picture); } Navigator.pop(context); // Just closing the BottomSheet }

Provider addPicture()
void addPicture(File picture) { _pictures.add(picture); notifyListeners(); }

It looks like the image gets stuck on some cache, but i have no mean to debug it as i don't have a mac environment

@vincentderidder
Copy link

Same issue. I'm using a multi image picker, and only the last image works.
Looking in the source code and logs, it seems that the image is saved as 'apple.jpg' in a temp directory. Meaning if you have multiple calls running at the same time, the image will be overwritten. (and explains why we only have our last image)

I'm nog comfortable enough with Swift to submit a fix, but possibly a unique ID as filename for each image would solve this issue.

@bkoznov
Copy link
Contributor

bkoznov commented Jun 4, 2020

I also had the same issue with a multi image picker. Thanks to @vincentderidder 's idea, a new PR is up and waiting to be merged in. #30

@NGhebreial
Copy link
Owner

PR is merged and published, can you try it and tell me if this is still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants