0

I'm having trouble saving the picked image permanently on my application, whenever I move to a new screen the image disappears it kills the path, here is my code below:

type Future<File?> pickImages(BuildContext context)async{
File? image;
try{
  final pickedImage = await ImagePicker().pickImage(source: ImageSource.gallery);
  if(pickedImage != null){
    image = File(pickedImage.path);
  }
} catch (e){
  print(e);
}
return image;
}

// for selecting the image
void  selectImage()async{
  image = await  pickImages(context);
  setState(() {
    
  });
}here

I have tried a few methods but run into the same error

  • image_picker library is only used for picking images,not for storing,if you want to store an image after picking the image you can use shared preference,like this https://stackoverflow.com/questions/51338041/how-to-save-image-file-in-flutter-file-selected-using-image-picker-plugin – Shirsh Shukla Apr 21 '23 at 07:35

0 Answers0