gal 1.8.0 copy "gal: ^1.8.0" to clipboard
gal: ^1.8.0 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 leave a like👍 and star⭐️ for more features.

Support iOS 11.0+ Android SDK 21+
Example ios android

✨Features #

  • Open gallery
  • Save video (to album)
  • Save image (to album)
  • 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" />

you can copy from AndroidManifest.xml in example.

✅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);

Handle Permission #

// Check Permission
await Gal.hasAccess();

// Request Permission
await Gal.requestAccess();

🎯Example #

Here is a minimal example. A best practice and more detailed one can be found in example folder.

import 'package:flutter/material.dart';
import 'package:gal/gal.dart';

void main() => runApp(const App());

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: [
            FilledButton.icon(
              onPressed: () async => Gal.open(),
              label: const Text('Open Gallery'),
              icon: const Icon(Icons.open_in_new),
            ),
            FilledButton.icon(
              onPressed: () async =>
                  Gal.putVideo('TODO: Change this text to video path'),
              label: const Text('Save Video'),
              icon: const Icon(Icons.video_file),
            ),
            FilledButton.icon(
              onPressed: () async =>
                  Gal.putImage('TODO: Change this text to image path'),
              label: const Text('Save Image'),
              icon: const Icon(Icons.image),
            ),
          ],
        ),
      ),
    );
  }
}

📪FAQ #

  • What is the best practice? #

    Please see Best Practice in project wiki.

  • I have a question. #

    Please see the Wiki first. If that didn't solve the problem. You should go to the Discussion. Once you are sure there are no duplicates, please ask them through Q&A.

💚Contributing #

Welcome! Feel free to create issue or PR. We kindly suggest considering to read this very short guide.

183
likes
0
pub points
97%
popularity

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

Topics

#gallery #video #image #photos #util

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on gal