vision_gallery_saver 1.0.0 copy "vision_gallery_saver: ^1.0.0" to clipboard
vision_gallery_saver: ^1.0.0 copied to clipboard

A Flutter plugin to save images and videos to the gallery on iOS and Android. Save images from widgets, network, and files.

vision_gallery_saver #

A Flutter plugin for saving images and videos to the gallery on iOS and Android platforms.

pub package License: MIT

Features #

  • 🖼️ Save images from widgets to gallery
  • 🌐 Save images from network URLs
  • 📹 Save videos from local files or URLs
  • 🎨 Support for custom quality settings
  • 📝 Custom file naming
  • ✨ Support for PNG, JPG, GIF formats
  • 📱 Works on both iOS and Android

Getting Started #

Add this to your package's pubspec.yaml file:

dependencies:
  vision_gallery_saver: ^1.0.0

Platform Setup #

iOS

Add the following keys to your Info.plist file:

<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to save photos and videos to your gallery.</string>

Android

For Android 10 (API level 29) and above, add this to your AndroidManifest.xml:

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

Usage #

Save a Widget as Image #

// Using GlobalKey with RepaintBoundary
final GlobalKey _globalKey = GlobalKey();

// Inside your widget tree
RepaintBoundary(
  key: _globalKey,
  child: YourWidget(),
)

// Save the widget
RenderRepaintBoundary boundary = _globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage();
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData != null) {
  final result = await VisionGallerySaver.saveImage(
    byteData.buffer.asUint8List(),
    quality: 100,
    name: "my_image"
  );
  print(result);
}

Save Network Image #

var response = await Dio().get(
    "https://example.com/image.jpg",
    options: Options(responseType: ResponseType.bytes));
final result = await VisionGallerySaver.saveImage(
    Uint8List.fromList(response.data),
    quality: 100,
    name: "network_image"
);

Save Video File #

final result = await VisionGallerySaver.saveFile(
    "/path/to/video.mp4",
    name: "my_video"
);

Example App #

Check out the example folder for a complete demo app showcasing all features.

API Reference #

VisionGallerySaver.saveImage() #

static Future<Map<dynamic, dynamic>> saveImage(
  Uint8List imageBytes, {
  int quality = 80,
  String? name,
  bool isReturnImagePathOfIOS = false
})

VisionGallerySaver.saveFile() #

static Future<Map<dynamic, dynamic>> saveFile(
  String file, {
  String? name,
  bool isReturnPathOfIOS = false
})

Return Value Format #

Methods return a Map with the following structure:

{
  "isSuccess": true/false,
  "filePath": "path/to/saved/file",  // Optional
  "errorMessage": "error message"     // If isSuccess is false
}

Contributing #

Contributions are welcome! Please read our contributing guidelines to get started.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

5
likes
160
points
1.34k
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to save images and videos to the gallery on iOS and Android. Save images from widgets, network, and files.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on vision_gallery_saver