Imagepicker always pick the previous image

Viewed 32

I have a code where user can add image and remove it, however once user remove the the image and want to add a new one, the app will always select the previous image, is there a reason why?

PickedFile pickedFile = await ImagePicker()
    .getImage(source: ImageSource.gallery, imageQuality: 50);

if (pickedFile != null) {
    var path = pickedFile.path;
    var lastSeparator = path.lastIndexOf(Platform.pathSeparator);
    var newPath = path.substring(0, lastSeparator + 1) +
        'customfilename.jpg';
    fv = await File(pickedFile.path).rename(newPath);
}
0 Answers
Related