gal 1.9.1 copy "gal: ^1.9.1" to clipboard
gal: ^1.9.1 copied to clipboard

Gal is a Flutter plugin for saving image/video to gallary app. You can also easily handle permissions.

Gal πŸ–ΌοΈ #

pub points Maintainability CodeFactor Codacy Badge CI License pub package

Please likeπŸ‘ and star⭐️ for more features.

Support iOS 11.0+ Android SDK 21+
Example ios android

✨ Features #

  • Open gallery
  • Save video
  • Save image
  • Save to album
  • Save with metadata
  • Handle permission
  • Handle errors
  • Lots of docs and wiki

πŸš€ Get started #

Add dependency #

You can use the command to add gal as a dependency with the latest stable version:

$ flutter pub add gal

iOS #

Add the following key to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • <key>NSPhotoLibraryAddUsageDescription</key>
  • <key>NSPhotoLibraryUsageDescription</key> Requried If you want to save media to album.

you can copy from Info.plist in example.

Android (API <29) #

Add the following key to your AndroidManifest file, located in <project root>/android/app/src/main/AndroidManifest.xml:

  • <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
  • android:requestLegacyExternalStorage="true" Requried If you want to save media to album in Android 10.

you can copy from AndroidManifest.xml in example.

πŸ”΄ Warning: Android emulators with API < 29 require SD card setup. Real devices don't.

βœ… Usage #

Save from local #

// Save Image (Supports two ways)
await Gal.putImage('$filePath');
await Gal.putImageBytes('$uint8List');

// Save Video
await Gal.putVideo('$filePath');

// Save to album
await Gal.putImage('$filePath', album: '$album')
...

Download from Internet #

$ flutter pub add dio
// Download Image
final imagePath = '${Directory.systemTemp.path}/image.jpg';
await Dio().download('$url',imagePath);
await Gal.putImage(imagePath);

// Download Video
final videoPath = '${Directory.systemTemp.path}/video.mp4';
await Dio().download('$url',videoPath);
await Gal.putVideo(videoPath);

Save from Camera #

$ flutter pub add image_picker
// Shot and Save
final image = await ImagePicker.pickImage(source: ImageSource.camera);
await Gal.putImage(image.path);
$ flutter pub add camera
// Record and Save
...
final video = await controller.stopVideoRecording();
await Gal.putVideo(video.path);

Handle Permission #

// Check Permission
await Gal.hasAccess();

// Request Permission
await Gal.requestAccess();

Handle Errors #

// Save Image with try-catch
try {
  await Gal.putImage($imagePath);
} on GalException catch (e) {
  log(e.type.message);
}

// Exception Type
enum GalExceptionType {
  accessDenied,
  notEnoughSpace,
  notSupportedFormat,
  unexpected;

  String get message => switch (this) {
        accessDenied => 'You do not have permission to access the gallery app.',
        notEnoughSpace => 'Not enough space for storage.',
        notSupportedFormat => 'Unsupported file formats.',
        unexpected => 'An unexpected error has occurred.',
      };
}

πŸ“ Ducuments #

183
likes
140
pub points
97%
popularity
screenshot

Publisher

verified publishermidoridesign.studio

Gal is a Flutter plugin for saving image/video to gallary app. You can also easily handle permissions.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#gallery #video #image #photos #util

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on gal