Home > Mobile >  How to display / delete the image after saving in the gallery?
How to display / delete the image after saving in the gallery?

Time:09-30

After saving the image in gallery using image_gallery_saver and permission_handler This is the result

file:///storage/emulated/0/Pictures/TestImage.jpg

my questions :

  • How to display the image in a container?
  • How to delete it ?

Note: I used image_picker in my app But I want to display the image after saving it automatically,

save image code is

 Future<String> saveImage (Uint8List bytes) async {
    await [Permission.storage].request();
    final name = 'TestImage';
    final result = await ImageGallerySaver.saveImage(bytes,name:name);
    print(result ["filePath"]);
    return result ["filePath"];
  }

CodePudding user response:

If you want the user to pick it from gallery, you can use image_picker but if you want to open it yourself from the path use:

Image.file(File(path))

Also for deleting you can use:

img = File(path)

Future<int> deleteFile() async {
        try {
          await file.delete();
        } catch (e) {
          return 0;
        }
      }

CodePudding user response:

    imageFile = await ImagePicker().getImage(
      source: ImageSource.gallery,
    );
  • Related