Skip to content

A flutter plugin to query the Native OS to get images from gallery.

License

Notifications You must be signed in to change notification settings

sirbardo/gallery_loader

Repository files navigation

gallery_loader

A flutter plugin to get paths of gallery images, both full-sized or at custom resolutions, from the native content providers.

Usage

Install

Just add this repo to your pubspec.yaml, like this:

gallery_loader:
   git: https://github.com/sirbardo/gallery_loader.git

Then, add the Permissions as explained below, and ask for permissions in your UI. I suggest using permission_handler as a plugin for this.

Android

Add this line to your android/app/src/main/AndroidManifest.xml

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

iOS

Add these lines to your Info.plist

	<key>NSPhotoLibraryUsageDescription</key>
	<string>We need to use the camera roll for this example app</string>

Using the plugin

Check the example app, but the main API is basically what you see in this snippet:

  Future<List<String>> getImages(
      {total: 1, startingIndex: 0, width: 0, height: 0}) async {
    final images = await GalleryLoader.getGalleryImages(
        total: total,
        startingIndex: startingIndex,
        targetWidth: width,
        targetHeight: height);
    return images;
  }

  Future<void> getImageCount() async {
    int totalImages = await GalleryLoader.getNumberOfImages();
    setState(() {
      _totalImages = totalImages;
    });
  }

About

A flutter plugin to query the Native OS to get images from gallery.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published