Configure Windows setup
mainC++ 20. If compilation fails, try downloading the latest Windows SDK via the Visual Studio Installer.repository·main·Indexed 42 days ago
https://github.com/natsuk4ze/galA Dart 3 plugin for Flutter applications to save images and videos directly to the device's photo gallery or specific albums across multiple platforms. It provides the Gal class for media operations and GalException for structured error handling, including categories like accessDenied, notEnoughSpace, and notSupportedFormat.
C++ 20. If compilation fails, try downloading the latest Windows SDK via the Visual Studio Installer.To change the launch screen image for your iOS application, you can use one of two methods:
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory with your own assets.open ios/Runner.xcworkspace.Runner/Assets.xcassets.open ios/Runner.xcworkspacegal package. To use it on Linux, you must use the federated plugin gal_linux.Add the following keys to your ios/Runner/Info.plist file to allow the app to access and save to the photo library.
NSPhotoLibraryAddUsageDescription: Required for saving images/videos.NSPhotoLibraryUsageDescription: Required for iOS versions older than 14, or when saving specifically to an album.Update android/app/src/main/AndroidManifest.xml with the following requirements:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />android:requestLegacyExternalStorage="true" to the <application> tag.Note: Android emulators with API < 29 require an SD card setup; real devices do not.
Add the following keys to macos/Runner/Info.plist:
NSPhotoLibraryAddUsageDescription: Required for saving.NSPhotoLibraryUsageDescription: Required for saving to an album.To use Gal in your Flutter project, add the latest stable version to your pubspec.yaml using the Flutter CLI.
flutter pub add galTo save media from a URL, first download the file to a temporary directory (e.g., using dio) and then pass the local path to Gal.
// Requires 'dio' package
// 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);Integrate with image_picker or camera packages to capture media and immediately save it to the gallery.
// Using image_picker
// Requires 'image_picker' package
final image = await ImagePicker.pickImage(source: ImageSource.camera);
await Gal.putImage(image.path);
// Using camera
// Requires 'camera' package
// ... capture video logic
final video = await controller.stopVideoRecording();
await Gal.putVideo(video.path);When performing gallery operations, wrap calls in a try-catch block to handle GalException. The exception provides a type which can be used to determine the cause of the failure.
try {
await Gal.putImage('$filePath');
} on GalException catch (e) {
log(e.type.message);
}
// GalExceptionType includes:
// - accessDenied
// - notEnoughSpace
// - notSupportedFormat
// - unexpectedBefore saving media, you should check and request access to the photo library. You can also specify if you are requesting access specifically for album operations.
// Check Access Permission
final hasAccess = await Gal.hasAccess();
// Request Access Permission
await Gal.requestAccess();
// ... for saving to album
final hasAccess = await Gal.hasAccess(toAlbum: true);
await Gal.requestAccess(toAlbum: true);Use the Gal class to save media from local file paths, bytes, or specific albums.
// 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');