简体   繁体   中英

How can I save a picture on screen from a button in flutter app

I am new to Flutter. I want to save a picture displayed on the screen in the gallery by using an icon button. I just want when somebody clicks on the button picture is saved in the gallery. How I can do that?

Use this package to solve the problem.

or you can try this also .

you can use image_gallery_saver .

  1. Add to your dependencies:

    dependencies: image_gallery_saver: '^1.7.1'

  2. Ask for storage permission to save an image to the gallery.

    <application android:requestLegacyExternalStorage="true".....>

Example saving images:

_save() async {
   var response = await Dio().get(
           "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg",
           options: Options(responseType: ResponseType.bytes));
   final result = await ImageGallerySaver.saveImage(
           Uint8List.fromList(response.data),
           quality: 60,
           name: "hello");
   print(result);
  }
GallerySaver.saveImage(image.path);

Using the gallery_saver dependency from pub.dev

Link: https://pub.dev/packages/gallery_saver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM