Sitelet https://github.com/flutter/flutter/issues/72125
Skip to content

image picker issue : random lost of image after several days  #72125

Description

@nitneuq33000

Hello, I add image picker package and successed to display image from gallery or camera. But after launch in prod I have serveral users with an issue.

When user select or take a picture, the image is display and save. After live test with user and after closing app and reload app, in same day I havn't issue. But after 1 or 2 days, user said me that image disappear...

here is the UI part

ClipRRect(
              borderRadius: BorderRadius.circular(20.0),
              child:  new Container(
                  width: MediaQuery.of(context).size.width/2,
                  height: MediaQuery.of(context).size.width/2,
                  decoration: new BoxDecoration(
                      image: new DecorationImage(
                          image: FileImage(File("${eventData.data10}")),
                          fit: BoxFit.cover
                      ))
              ),
            )

Here is my save path part

File _image_picker;
final picker = ImagePicker();

Future getImage() async {
   SharedPreferences prefs = await SharedPreferences.getInstance();
   final pickedFile = await picker.getImage(source: ImageSource.gallery);
   setState(() {
     if (pickedFile != null) {
       _image_picker = File(pickedFile.path);
       prefs.setString('path_image_picker',pickedFile.path);
     } else {
       print('No image selected.');
     }
   });
 }

Here is my load path part

load_image()async{
   SharedPreferences prefs = await SharedPreferences.getInstance();
   setState(() {
    var  path_image_picker=prefs.getString('path_image_picker');
       _image_picker = File("$path_image_picker");
     
   });

 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions