gallery_asset_picker 0.0.4 copy "gallery_asset_picker: ^0.0.4" to clipboard
gallery_asset_picker: ^0.0.4 copied to clipboard

Medias picker which is inspired by modern app.

Gallery Asset Picker #

A gallery picker and camera in one package. The Gallery and Camera views can both be utilized as Flutter widgets


Table of contents #


Screenshot #

Collapse Mode Expand Mode
image1 image2

Install #

1. Add dependency #

Add this to your package's pubspec.yaml file:

dependencies:
  gallery_asset_picker: ^latest_version
copied to clipboard

2. Import it #

Now in your Dart code, you can use:

import 'package:gallery_asset_picker/gallery_asset_picker.dart';
copied to clipboard

Setup #

For more details (if needed) you can go through Photo Manager and Camera readme section as well.

1. Android #

  • Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.
minSdkVersion 21
copied to clipboard
  • Required permissions: READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, ACCESS_MEDIA_LOCATION.

  • Glide

Android native use glide to create image thumb bytes, version is 4.11.0.

If your other android library use the library, and version is not same, then you need edit your android project's build.gradle.

rootProject.allprojects {

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.github.bumptech.glide'
                        && details.requested.name.contains('glide')) {
                    details.useVersion '4.11.0'
                }
            }
        }
    }
}
copied to clipboard

If you found some warning logs with Glide appearing, then the main project needs an implementation of AppGlideModule. See Generated API.

2. iOS #

Add following content to info.plist.

<key>NSPhotoLibraryUsageDescription</key>
<string>Replace with your permission description..</string>
<key>NSCameraUsageDescription</key>
<string>Replace with your permission description..</string>
copied to clipboard

Usage #

  • Use GalleryAssetPicker.initialize to config for the gallery
GalleryAssetPicker.initialize(GalleryConfig(
    enableCamera: true,
    crossAxisCount: 3,
    colorScheme: const ColorScheme.light(primary: Colors.blue),
    onReachMaximum: () {
      Fluttertoast.showToast(
        msg: "You have reached the allowed number of images",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        textColor: Colors.white,
        fontSize: 16.0,
      );
    },
    textTheme: const TextTheme(
      bodyMedium: TextStyle(fontSize: 16),
      titleMedium: TextStyle(fontSize: 14, fontWeight: FontWeight.w700),
      titleSmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
    ),
));
copied to clipboard
  • To make the gallery view sliding, use the SlidableGalleryOverlay; otherwise, ignore it
class SlidableGalleryDemo extends StatelessWidget {
 late final GalleryController galleryController;

 ...

 @override
 Widget build(BuildContext context) {
   return SlidableGalleryOverlay(
     controller: galleryController,
     child: Scaffold(
       body: ...
     ),
   );
 }
}
copied to clipboard
  • Using GalleryAssetPicker.pick() to pick assets
  ...
  onPressed : () async {
    final _selectedAssets = await GalleryAssetPicker.pick(
      context,
      maxCount: 5,
      requestType: RequestType.image,
    );
  }
  ...
copied to clipboard
  • You can use other widgets included in the package, and for a more thorough implementation and modification, browse the example app

Bugs or Requests #

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.

8
likes
80
points
65
downloads

Publisher

unverified uploader

Weekly Downloads

2024.07.05 - 2025.01.17

Medias picker which is inspired by modern app.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

camera, collection, flutter, intl, meta, path, photo_manager, uuid

More

Packages that depend on gallery_asset_picker