Ā Ā·Ā Stranger

Save photo from ImagePath Url to local device gallery

Using 2 packages and creating 1 custom action: Custom action (named savePhoto)


import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:dio/dio.dart';

Future savePhoto(String imageUrl) async {
  var response = await Dio()
      .get(imageUrl, options: Options(responseType: ResponseType.bytes));
  final result = await ImageGallerySaver.saveImage(
    Uint8List.fromList(response.data),
  );
  print(result);
}

Don't forget to add 2 dependancies:Ā  image_gallery_saver: ^1.7.1 dio: ^4.0.0Add 1 parameter:Ā  String(ImagePath) imageUrlRefer to the photo below to double check[į„‰į…³į„į…³į„…į…µį†«į„‰į…£į†ŗ 2023-05-07 į„‹į…©į„’į…® 3.21.59.png]Lastly you should add Permission:Ā  • Setting > Project Setup > Permissions > Photo Library: Turn it on and enter a message.

2
2 replies