media_gallery_saver

This plug-in allows you to save files to the iOS and Android galleries from url, asset, and file. If authorization is required when saving, an authorization dialog will appear.

Supported Files

  • jpg
  • png
  • gif
  • webp
  • heic
  • mp4
  • mov

Usage

# pubspec.yaml
dependencies:
  media_gallery_saver: ^1.2.0

iOS

To obtain permission to save, you must set NSPhotLibraryUsageDescription in the info.plist of the project you wish to use.

<key>NSPhotoLibraryUsageDescription</key>
<string>Why authority is needed</string>

Android

uses-permission is set in the internal AndroidManifest.

Example

File file = File("Path of the file you want to save.");

MediaGallerySaver().saveMediaFromUrl(
  url: "https://example.com/image.jpg",
  quality: 100, // default 100%
);

Options

MediaGallerySaver accepts options in the constructor.

  • connectTimeout: Connection timeout in milliseconds (default: 15000ms)
  • readTimeout: Read timeout in milliseconds (default: 0 = unlimited)
final saver = MediaGallerySaver(
  options: MediaGallerySaverOptions(
    connectTimeout: 30000, // 30 seconds
    readTimeout: 120000, // 2 minutes
  ),
);