flutterdartflutter-dependencies

how to save uint8list to gallery as png


I'm working on a project that captures a screenshot of a widget and saves it in gallery. my problem is there is few save to gallery packages in flutter and I tries almost all of them! they save images as jpg which adds extra black bars around my widget which I don't want them to be there. is there any package to save images to gallery in PNG format?


Solution

  • I've found the solution after 2 days of struggling with that. you should save file as PNG to device path then use image_gallery_saver package to save it as file

     File('$dir/file_name${DateTime.now()}.png').writeAsBytes(pngBytes!);
     final result = await ImageGallerySaver.saveFile(imagePath);