gal

Creator: coderz1093

Last updated:

Add to Cart

Description:

gal

Gal


Dart3 plugin for saving image or video to photos gallery




pub.dev Β»


















Please LIKEπŸ‘ and STAR⭐️ to support our volunteer efforts. #
Support means that all functions have been tested manually or automatically whenever possible.




Android
iOS
macOS
Windows
Linux




Support
SDK 21+
11+
11+
10+
See: gal_linux







iOS
Android




Example





✨ 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
copied to clipboard
iOS #
Add the following keys to the ios/Runner/Info.plist:

<key>NSPhotoLibraryAddUsageDescription</key> Required
<key>NSPhotoLibraryUsageDescription</key> Required for ios < 14 or saving to album

You can copy from Info.plist in example.
Android #
Add the following keys to the android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" /> Required for API <= 29
android:requestLegacyExternalStorage="true" Required for saving to the album in API 29

You can copy from AndroidManifest.xml from example.

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

macOS #
Add the following keys to the macos/Runner/Info.plist:

<key>NSPhotoLibraryAddUsageDescription</key> Required
<key>NSPhotoLibraryUsageDescription</key> Required for saving to album

You can copy from Info.plist in example.

πŸ”΄ Warning:
Flutter currently has a fatal problem for loading info.plist, and permissions are always denied in
some code editors.

Windows #
Update Visual Studio to the latest version for using C++ 20.

πŸ’‘ If you can't compile
Try downloading a latest Windows SDK:

Open Visual Studio Installer
Select Modify
Select Windows SDK


Linux #
Currently does not officially support Linux, but it can be added through a community plugin.
See: gal_linux
βœ… 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')
...
copied to clipboard
Download from the Internet #
$ flutter pub add dio
copied to clipboard
// 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);
copied to clipboard
Save from Camera #
$ flutter pub add image_picker
copied to clipboard
// Shot and Save
final image = await ImagePicker.pickImage(source: ImageSource.camera);
await Gal.putImage(image.path);
copied to clipboard
$ flutter pub add camera
copied to clipboard
// Record and Save
...
final video = await controller.stopVideoRecording();
await Gal.putVideo(video.path);
copied to clipboard
Handle Permission #
// Check for access premission
final hasAccess = await Gal.hasAccess();

// Request access premission
await Gal.requestAccess();

// ... for saving to album
final hasAccess = await Gal.hasAccess(toAlbum: true);
await Gal.requestAccess(toAlbum: true);
copied to clipboard
Handle Errors #
// Save Image with try-catch
try {
await Gal.putImage('$filePath');
} on GalException catch (e) {
log(e.type.message);
}

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

String get message => switch (this) {
accessDenied => 'Permission to access the gallery is denied.',
notEnoughSpace => 'Not enough space for storage.',
notSupportedFormat => 'Unsupported file formats.',
unexpected => 'An unexpected error has occurred.',
};
}
copied to clipboard
πŸ“ Ducuments #
If you write an article about Gal, let us know in discussion and we will post the URL of the article in the wiki or readme 🀝


🎯 Example #


πŸ‘Œ Best Practice #


🏠 Wiki #


πŸ’š Contributing #


πŸ’¬ Q&A #


πŸ’š Trusted by huge projects #
Although Gal has only been released for a short time, it is already trusted by huge projects.


localsend - 28k⭐️ #


flutter-quill-extensions - 2.3k⭐️ #


Thunder - 660⭐️ #
and more...

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.